@bino-bi/bn-template-engine 1.0.0-next.62 → 1.0.0-next.63

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 (24) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-24a8322b.entry.js → p-7b74696e.entry.js} +1 -1
  3. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +669 -261
  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-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +8 -8
  7. package/dist/collection/components/bn-chart-time/bn-chart-time.js +115 -34
  8. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +515 -216
  9. package/dist/collection/components/bn-chart-time/utils/helper/ElementPositions.js +23 -1
  10. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +15 -8
  11. package/dist/components/bn-chart-time-renderer.js +1 -1
  12. package/dist/components/bn-chart-time.js +1 -1
  13. package/dist/components/p-C3-kXJUZ.js +1 -0
  14. package/dist/esm/bn-annotation-layer_30.entry.js +669 -261
  15. package/dist/esm/bn-template-engine.js +1 -1
  16. package/dist/esm/loader.js +1 -1
  17. package/dist/types/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.d.ts +2 -2
  18. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +29 -16
  19. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +63 -30
  20. package/dist/types/components/bn-chart-time/utils/helper/ElementPositions.d.ts +8 -0
  21. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +16 -7
  22. package/dist/types/components.d.ts +8 -8
  23. package/package.json +1 -1
  24. package/dist/components/p-Cj1iKmdF.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,e as o,F as h}from"./p-GstO_GU5.js";import{S as a,w as l,a as c,g as u,C as d,r as f,c as v,h as p,d as g,e as m,X as b,i as y,D as w,j as x,m as S,s as $,k as M,l as _,u as k,n as O}from"./p-B6SpWzpW.js";import{a as N,m as A,C as R,i as L,b as T,w as E,c as C,r as P,s as W,d as D,e as z,f as U,v as F,g as G,A as j,O as I,h as B,j as Y,k as H,l as V,n as X,o as J,p as q,q as K,S as Q,t as Z,u as tt,x as it,y as st,N as et,z as nt,B as rt,D as ot,E as ht,F as at,G as lt,H as ct,I as ut,R as dt,J as ft,K as vt,L as pt,M as gt,P as mt,Q as bt,T as yt,U as wt,V as xt,W as St,X as $t,Y as Mt,Z as _t,_ as kt,$ as Ot,a0 as Nt,a1 as At,a2 as Rt,a3 as Lt,a4 as Tt,a5 as Et,a6 as Ct,a7 as Pt,a8 as Wt,a9 as Dt,aa as zt,ab as Ut,ac as Ft,ad as Gt,ae as jt,af as It,ag as Bt,ah as Yt,ai as Ht}from"./p-BXkVoFbt.js";import{s as Vt,g as Xt,b as Jt,i as qt,f as Kt,r as Qt,a as Zt,w as ti,p as ii,c as si,d as ei,e as ni,h as ri,j as oi}from"./p-DBRtHV59.js";import{w as hi}from"./p-CZmA8CIL.js";import{r as ai,m as li,a as ci,l as ui,o as di,b as fi,c as vi,t as pi,d as gi,e as mi}from"./p-CzzF-PBk.js";import{L as bi}from"./p-DY5fMUX8.js";import{e as yi,r as wi}from"./p-ClruFZD_.js";import{I as xi,S as Si,D as $i,b as Mi}from"./p-hV2evPFR.js";const _i=/^[a-z][a-z0-9-]*$/i;function ki(t,i){var s,e;const n=null!==(s=null==i?void 0:i.color)&&void 0!==s?s:a["bn-annotation"].color,r=null!==(e=null==i?void 0:i.colors)&&void 0!==e?e:{},o=`var(--bn-annotation-color, ${n})`;if(!t||!_i.test(t))return o;const h=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;return`var(--bn-annotation-color-${t}, ${null!=h?h:o})`}const Oi=t=>"string"==typeof t||"number"==typeof t?String(t):void 0;function Ni(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 Ai=new WeakMap;let Ri=1;function Li(t){const i=t.closest("bn-layout-page");if(!i)return"";let s=Ai.get(i);return s||(s="page-"+Ri++,Ai.set(i,s)),s}const Ti=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function Ei(t,i){const s=Ti(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 Ci(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 Pi=(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 Wi(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=>Pi(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))}}const Di=(t,i)=>.6*t.length*i,zi=(t,i)=>(t<0?"-":"+")+Math.abs(t).toFixed(i);function Ui(t,i,s,e,n,r,o){var h,a,l;if(null==e||null==n)return;const c=n-e,u=Number.isInteger(t.digits)&&t.digits>=0?t.digits:1,d="good-down"===t.sentiment?c<=0:c>=0,f=s.x+s.width/2>=i.x+i.width/2?1:-1,v=t=>1===f?t.x+t.width:t.x,p=v(s)+.9*f*r,g=p+.125*f*r,m=null!==(h=null==o?void 0:o.from)&&void 0!==h?h:i.y,b=null!==(a=null==o?void 0:o.to)&&void 0!==a?a:s.y,y=.25*r,w=t.percent&&0!==e?`(${zi(c/Math.abs(e)*100,0)}%)`:void 0,x=zi(c,u),S=p+.6*f*r,$=(m+b)/2,M=w?Di(w,.85*r):0,_=1===f?S+.5*x.length*r+.35*r:S-M;return{kind:"difference",color:null!==(l=t.color)&&void 0!==l?l:d?"positive":"negative",lines:[{x1:v(i),y1:m,x2:g,y2:m},{x1:v(s),y1:b,x2:g,y2:b}],bar:{x:p-y/2,y:Math.min(m,b),width:y,height:Math.max(Math.abs(b-m),1)},text:{x:S,y:$,anchor:1===f?"start":"end",value:x,percent:w},frame:w&&t.highlight?{x:_-.25*r,y:$-.65*r,width:M+.5*r,height:1.3*r,r:.65*r}:void 0,badge:null!=t.label?{cx:p,cy:Math.min(m,b)-.9*r,r:.65*r,label:t.label}:void 0}}function Fi(t,i,s,e,n={}){var r,o,h,a;const{label:l,color:c}=t,{whole:u,area:d,text:f}=n,v=!u&&!f&&null!=n.obstacles,p=((t,i)=>t?Math.min(i,t.height/1.3):i)(null!=f?f:v?i:void 0,e);if("arrow"===t.mark){if(!s)return;const t=Ti(i),n=Ti(s);if(t.x===n.x&&t.y===n.y)return;let r=Ei(i,n),o=Ei(s,t);(o.x-r.x)*(n.x-t.x)+(o.y-r.y)*(n.y-t.y)<=0&&(r=t,o=n);const h=Math.hypot(o.x-r.x,o.y-r.y),a=Math.min(.8*e,h),u=(o.x-r.x)/h,f=(o.y-r.y)/h,v=o.x-u*a,p=o.y-f*a,g=.35*e;return{kind:"arrow",color:c,x1:r.x,y1:r.y,x2:v,y2:p,head:[`${o.x},${o.y}`,`${v-f*g},${p+u*g}`,`${v+f*g},${p-u*g}`].join(" "),badge:null!=l?Ci({cx:r.x,cy:r.y,r:.65*e,label:l},d):void 0}}if("frame"===t.mark){const s=null==t.text||u?void 0:n.label?"above"===t.textPosition?{x:i.x+i.width/2+.5*e,y:i.y-.8*e}:{x:i.x+i.width+.7*e+Di(t.text,e)/2,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y+Math.min(i.height/2,Math.max(.9*e,.3*i.height))},h=s&&{x:s.x-Di(t.text,e)/2,y:s.y-.6*e,width:Di(t.text,e),height:1.2*e},a=null!==(r=null!=h?h:f)&&void 0!==r?r:i,v=null===(o=t.point)||void 0===o?void 0:o.part,g=!u&&(null!=h||null!=f||"label"===v||"total"===v),m=(g?.45:.2)*p,b=(g?.1:.2)*p,y=g?Math.max(a.width,a.height):a.width,w=a.x+a.width/2,x=1,S=Math.max(d?x:-1/0,w-y/2-m),$=Math.max(d?x:-1/0,a.y-b),M=Math.min(d?d.width-x:1/0,w+y/2+m),_=Math.min(d?d.height-x:1/0,a.y+a.height+b),k=Math.min(M-S,_-$)/2,O=u?.25*e:k,N=u?.25*e:g?Math.min((M-S)/2,1.6*k):k,A=1-Math.SQRT1_2,R=.65*p,L=g?.6*R:0;return{kind:"frame",color:c,x:S,y:$,width:M-S,height:_-$,rx:N,ry:O,badge:null!=l?Ci({cx:M-N*A+L,cy:$+O*A-L,r:R,label:l},d):void 0,caption:s&&Object.assign(Object.assign({},s),{text:t.text})}}if(f&&!u){const t=Wi(f,(null==l?.4:.65)*p,p,n);return{kind:"marker",color:c,badge:Ci({cx:t.x,cy:t.y,r:t.r,label:l},d)}}const g=(null==l?.4:.75)*p,m=v?Math.min(g,i.height/2):g;let b=u?{x:i.x+i.width-m,y:i.y+m}:Ti(i);if(!u&&n.label)b={x:i.x+i.width+.25*p+m,y:i.y+i.height/2};else if(!u&&n.stacked&&n.horizontal){const t=1.3*p+m;b=i.width/2>=t+m?{x:i.x+i.width/2+t,y:i.y+i.height/2}:{x:i.x+i.width-Math.min(m,i.width/2),y:i.y}}else!u&&n.stacked&&"label"!==(null===(h=t.point)||void 0===h?void 0:h.part)&&"total"!==(null===(a=t.point)||void 0===a?void 0:a.part)&&(b={x:i.x+i.width,y:i.y+Math.min(.5*m,i.height/2)});if(v){const t={x:b.x-m,y:b.y-m,width:2*m,height:2*m},i=n.obstacles.find((i=>Pi(t,i)));if(i){const t=Wi(i,m,p,n);return{kind:"marker",color:c,badge:Ci({cx:t.x,cy:t.y,r:t.r,label:l},d)}}}return{kind:"marker",color:c,badge:Ci({cx:b.x,cy:b.y,r:m,label:l},d)}}function Gi(t,i,s,e,n,r,o){var h;if(null==e||null==n)return;const a=n-e,l=Number.isInteger(t.digits)&&t.digits>=0?t.digits:1,c="good-down"===t.sentiment?a<=0:a>=0,u=s.y+s.height/2>=i.y+i.height/2?1:-1,d=t=>1===u?t.y+t.height:t.y,f=.25*r,v=d(s)+.25*u*r,p=Math.min(o.from,o.to),g=Math.max(o.from,o.to),m=t.percent&&0!==e?`(${zi(a/Math.abs(e)*100,0)}%)`:void 0,b=zi(a,l),y=g+.5*r,w=.5*b.length*r,x=m?Di(m,.85*r):0,S=y+w+.35*r;return{kind:"difference",color:null!==(h=t.color)&&void 0!==h?h:c?"positive":"negative",lines:[{x1:o.from,y1:d(i),x2:o.from,y2:v},{x1:o.to,y1:d(s),x2:o.to,y2:v}],bar:{x:p,y:v-f/2,width:Math.max(g-p,1),height:f},text:{x:y,y:v,anchor:"start",value:b,percent:m},frame:m&&t.highlight?{x:S-.25*r,y:v-.65*r,width:x+.5*r,height:1.3*r,r:.65*r}:void 0,badge:null!=t.label?{cx:p-.9*r,cy:v,r:.65*r,label:t.label}:void 0}}function ji(t,i,s){const e=i.x,n=i.y-.15*s,r=n-.7*s,o=n-1.9*s,h=.55*s,a=.22*s;return{kind:"pointer",color:t.color,shape:[[e,n],[e-h,r],[e-a,r],[e-a,o],[e+a,o],[e+a,r],[e+h,r]].map((([t,i])=>`${t},${i}`)).join(" "),badge:null!=t.label?{cx:e+1.1*s,cy:o+.65*s,r:.65*s,label:t.label}:void 0}}function Ii(t,i,s,e,n,r,o){const h=i.y<=s.y,[a,l]=h?[i,s]:[s,i],[c,u]=h?[e.first,e.last]:[e.last,e.first],d=l.y+l.height+.2*o,f=[[n,d],[u,d],[c,a.y-.1*o]],v=r?Di(r,o):0,p=(a.y+l.y+l.height)/2,g=r?{x:n+.5*o+v/2,y:p,text:r}:void 0,m=g?g.x+v/2+1.2*o:n+.65*o;return{kind:"bracket",color:t.color,path:f.map((([t,i])=>`${t},${i}`)).join(" "),caption:g,frame:g&&{x:g.x-v/2-.45*o,y:g.y-.7*o,width:v+.9*o,height:1.4*o,r:.7*o},badge:null!=t.label?{cx:m,cy:p,r:.65*o,label:t.label}:void 0}}const Bi=["rowGroup","category","subCategory","date","scenario","row"];function Yi(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"))&&Bi.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,value:e,scenario:n,kind:r})=>({rect:t,content:i,contentSign:s,value:e,stacked:"string"==typeof n&&n.startsWith("stack:"),label:"label"===r})))}function Hi(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 Vi=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function Xi(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 Ji=class{constructor(i){t(this,i),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.observedAround=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=l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){var t;this.stores=u(this.element),this.pageKey=Li(this.element),this.observed=new WeakSet,this.observedAround=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=Ni(t))||void 0===i?void 0:i.map((t=>{var i;return Object.assign(Object.assign({},t),{label:Oi(t.label),color:Oi(t.color),target:null!==(i=Oi(t.target))&&void 0!==i?i:"",to:Oi(t.to),text:Oi(t.text)})}))}(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,i,s,e;const n=++this.run;if(!this.element.isConnected||!this.svg)return;const r=this.element.closest("bn-layout-page"),o=new Map,h=new Map;null==r||r.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const i=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!Vi.has(t.localName))),s=null!=i?i:t;o.set(t.getAttribute("data-bino-annotation-target"),s),h.set(s,t)})),null==r||r.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const a=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),l=[...o].filter((([t])=>a.has(t))).map((([,t])=>t));if(await Promise.all(l.map((t=>{var i;return null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t)}))),n!==this.run)return;l.forEach((t=>{this.observe(t),this.observeAround(t,r)}));const c=new Map;if(await Promise.all(l.map((async t=>{var i;c.set(t,await(null===(i=t.getLayoutState)||void 0===i?void 0:i.call(t,{detail:"full"}).catch((()=>{}))))}))),n!==this.run)return;const u=(t,i)=>{var s;const e=null!=t?o.get(t):void 0;if(!e)return{problem:`no target "${t}" on this page`};const n=e.getBoundingClientRect();if(function(t){return!t||Bi.every((i=>null==t[i]))&&null==t.part}(i)){const i={x:n.left,y:n.top,width:n.width,height:n.height};return function(t,i,s){if(0===t.width||0===t.height||!Xi(t,s))return!0;for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Xi(t,s))return!0;return!1}(i,h.get(e),this.element)?{problem:`"${t}" cannot be seen`}:{box:i,whole:!0}}const r=c.get(e),a=r?Yi(r,i):[];if(1!==a.length)return{problem:`${a.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const l=({component:{x:t,y:i,width:s,height:e}})=>({x:n.left+t,y:n.top+i,width:s,height:e}),u=l(a[0].rect);if(function(t,i){for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Hi(t,s))return!0;return!1}(u,h.get(e))||!Hi(u,this.element))return{problem:`the point ${JSON.stringify(i)} in "${t}" is cut off`};const f=a[0].content;if(!r.table)return{box:u,whole:!1,stacked:a[0].stacked,label:a[0].label,horizontal:d(r)};const v=(null!==(s=r.elements)&&void 0!==s?s:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:l(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:f&&{box:l(f),sign:a[0].contentSign},obstacles:v}},d=t=>{var i;return(null!==(i=null==t?void 0:t.elements)&&void 0!==i?i:[]).some((t=>"axis"===t.kind&&"vertical"===t.orientation))},f=(t,i)=>{const s=null!=t?o.get(t):void 0;if(!s)return{problem:`no target "${t}" on this page`};const e=c.get(s),n=(e&&i?Yi(e,Object.assign(Object.assign({},i),{part:"element"})):[]).filter((t=>null!=t.value));if(0===n.length)return{problem:`no bar with a value matches the point ${JSON.stringify(i)} in "${t}"`};if(n.length>1&&!n.every((t=>t.stacked)))return{problem:`${n.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const r=s.getBoundingClientRect(),h=Math.min(...n.map((t=>t.rect.component.x))),a=Math.min(...n.map((t=>t.rect.component.y))),l=Math.max(...n.map((t=>t.rect.component.x+t.rect.component.width))),u=Math.max(...n.map((t=>t.rect.component.y+t.rect.component.height)));return{box:{x:r.left+h,y:r.top+a,width:l-h,height:u-a},negatives:n.filter((t=>t.value<0)).map((t=>{return{x:r.left+(i=t.rect.component).x,y:r.top+i.y,width:i.width,height:i.height};var i})),value:n.reduce(((t,i)=>t+i.value),0),horizontal:d(e)}},v=(t,i,s)=>{const e=o.get(t.target),n=e&&c.get(e);if(!e||!n||!t.point)return;const r=e.getBoundingClientRect(),h=function(t,i){var s={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(s[e[n]]=t[e[n]])}return s}(t.point,["rowGroup","category","subCategory","date"]),a=Yi(n,Object.assign(Object.assign({},h),{part:"element"})).filter((t=>null!=t.value)),l=a.reduce(((t,i)=>t+i.value),0),u=a.filter((t=>{const e=r.top+t.rect.component.y+t.rect.component.height/2;return e>=i.y&&e<=s.y+s.height})).reduce(((t,i)=>t+i.value),0);return 0!==l?u/l:void 0},p=this.toLocalSpace(),g=({box:t,sign:i=0})=>{const s=p(t);return Object.assign(Object.assign({},s),{x:s.x-i,width:s.width+i})},m=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,b={width:this.element.clientWidth,height:this.element.clientHeight},y=[],w=[];for(const n of this.parsedItems){if("difference"===n.mark){const i=f(n.target,n.point),s=f(null!==(t=n.to)&&void 0!==t?t:n.target,n.toPoint),e="problem"in i?i:"problem"in s?s:void 0;if(e){w.push({item:n,problem:e.problem});continue}const[r,o]=[i,s];if(r.horizontal){const t=t=>{const i=p(t.box);return i.x+i.width-t.negatives.reduce(((t,i)=>t+p(i).width),0)},i=Gi(n,p(r.box),p(o.box),r.value,o.value,m,{from:t(r),to:t(o)});i&&y.push(i);continue}const h=t=>p(t.box).y+t.negatives.reduce(((t,i)=>t+p(i).height),0),a=Ui(n,p(r.box),p(o.box),r.value,o.value,m,{from:h(r),to:h(o)});a&&y.push(a);continue}if("pointer"===n.mark||"bracket"===n.mark){const t=f(n.target,n.point),e="bracket"===n.mark?f(null!==(i=n.to)&&void 0!==i?i:n.target,n.toPoint):t,r="problem"in t?t:"problem"in e?e:void 0;if(r){w.push({item:n,problem:r.problem});continue}const[h,a]=[t,e],l=t=>{const i=p(t.box);return t.horizontal?{x:i.x+i.width-t.negatives.reduce(((t,i)=>t+p(i).width),0),y:i.y}:{x:i.x+i.width/2,y:i.y+t.negatives.reduce(((t,i)=>t+p(i).height),0)}};if("pointer"===n.mark){y.push(ji(n,l(h),m));continue}if(!h.horizontal){w.push({item:n,problem:"a bracket needs bars that run from left to right"});continue}if(null!=n.to&&n.to!==n.target){w.push({item:n,problem:"both ends of a bracket must be in one chart"});continue}const[c,u]=h.box.y<=a.box.y?[h.box,a.box]:[a.box,h.box],d=n.percent?v(n,c,u):void 0,g=o.get(n.target).getBoundingClientRect(),b=p({x:g.left,y:g.top,width:g.width,height:g.height}),x=null!==(s=n.text)&&void 0!==s?s:null!=d?`${Math.round(100*d)}%`:void 0;y.push(Ii(n,p(h.box),p(a.box),{first:l(h).x,last:l(a).x},b.x,x,m));continue}const r=u(n.target,n.point),h="arrow"===n.mark?u(n.to,n.toPoint):void 0,a="problem"in r?r:h&&"problem"in h?h:void 0;if(a){w.push({item:n,problem:a.problem});continue}const l=r,c=h,d=Fi(n,p(l.box),c&&p(c.box),m,{whole:l.whole,area:b,text:l.text&&g(l.text),obstacles:null===(e=l.obstacles)||void 0===e?void 0:e.map(g),stacked:l.stacked,label:l.label,horizontal:l.horizontal});d?y.push(d):w.push({item:n,problem:"an arrow needs two ends at different places"})}this.marks=y,this.storeUnplaced(w.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),w.length>0&&this.reportWhenQuiet(n,w)}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===d.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)}observeAround(t,i){var s,e;for(let n=t.parentElement;n&&n!==i;n=n.parentElement)this.observedAround.has(n)||(this.observedAround.add(n),null===(s=this.mutationObserver)||void 0===s||s.observe(n,{attributes:!0,attributeFilter:["style"]}),n.shadowRoot&&(null===(e=this.mutationObserver)||void 0===e||e.observe(n.shadowRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})))}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){var e;if(!t)return null;const n="outlined"===(null===(e=this.componentStyle((t=>t["bn-annotation"])))||void 0===e?void 0:e.markerStyle),r=i("circle",n?{cx:t.cx,cy:t.cy,r:t.r-.75,style:{fill:"#ffffff",stroke:s,strokeWidth:"1.5"}}:{cx:t.cx,cy:t.cy,r:t.r,style:{fill:s}});return i("g",null,r,null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:Object.assign({fontSize:1.1*t.r+"px"},n?{fill:s}:{})},t.label):null)}renderMark(t){var s,e,n,r,o;const h=ki(t.color,this.componentStyle((t=>t["bn-annotation"])));if("marker"===t.kind)return i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,h));if("frame"===t.kind)return 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:t.caption?"#ffffff":"none",stroke:h,strokeWidth:"1.5"}}),t.caption?i("text",{class:"mark-text caption",x:t.caption.x,y:t.caption.y},t.caption.text):null,this.renderBadge(t.badge,h));if("difference"===t.kind){const s=ki(void 0,this.componentStyle((t=>t["bn-annotation"])));return i("g",{class:"mark difference","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},t.lines.map((t=>i("line",{class:"difference-line",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}))),i("rect",{x:t.bar.x,y:t.bar.y,width:t.bar.width,height:t.bar.height,style:{fill:h}}),i("text",{class:"mark-text",x:t.text.x,y:t.text.y,style:{textAnchor:t.text.anchor}},t.text.value,t.text.percent?i("tspan",{class:"percent",dx:"0.35em"},t.text.percent):null),t.frame?i("rect",{x:t.frame.x,y:t.frame.y,width:t.frame.width,height:t.frame.height,rx:t.frame.r,ry:t.frame.r,style:{fill:"none",stroke:s,strokeWidth:"1.5"}}):null,this.renderBadge(t.badge,s))}return"pointer"===t.kind?i("g",{class:"mark pointer","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},i("polygon",{points:t.shape,style:{fill:h}}),this.renderBadge(t.badge,h)):"bracket"===t.kind?i("g",{class:"mark bracket","data-label":null===(r=t.badge)||void 0===r?void 0:r.label},i("polyline",{points:t.path,style:{fill:"none",stroke:h,strokeWidth:"1.5"}}),t.frame?i("rect",{x:t.frame.x,y:t.frame.y,width:t.frame.width,height:t.frame.height,rx:t.frame.r,ry:t.frame.r,style:{fill:"#ffffff",stroke:h,strokeWidth:"1.5"}}):null,t.caption?i("text",{class:"mark-text caption",x:t.caption.x,y:t.caption.y},t.caption.text):null,this.renderBadge(t.badge,h)):i("g",{class:"mark arrow","data-label":null===(o=t.badge)||void 0===o?void 0:o.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:h,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:h}}),this.renderBadge(t.badge,h))}render(){return i(s,{key:"370b2e099f2316d584f40b02b417576ecc541291"},i("svg",{key:"ba77a53b8fe0b9dbabe25d070a87a1841ed19998",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return e(this)}static get watchers(){return{items:[{onItemsChange:0}]}}};Ji.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}.mark-text{fill:#000000;dominant-baseline:central}.mark-text.caption{text-anchor:middle;font-size:0.9em}.mark-text .percent{font-size:0.85em}.difference-line{stroke:#000000;stroke-width:0.75}';const qi=class{constructor(i){t(this,i),this.pageKey="",l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){this.stores=u(this.element),this.pageKey=Li(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=Ni(t))||void 0===i?void 0:i.map((t=>({label:Oi(t.label),title:Oi(t.title),html:Oi(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=this.componentStyle((t=>t["bn-annotation"])),o=ki(void 0,r),h="outlined"===(null==r?void 0:r.markerStyle)?{background:"#ffffff",color:o,boxShadow:`inset 0 0 0 1.5px ${o}`}:{background:o},a=null!==(e=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==e?e:[];return i(s,{key:"ec249c8259923180f4bd30b8c712c0614a758911"},i("ol",{key:"6e8cbbe5a5841c8707081f9452b11c3971cecd03"},(null!=n?n:[]).map((t=>i("li",null,null==t.label||a.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:h},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:Vt(t.html)}):null))))))}get element(){return e(this)}};qi.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 Ki=class{constructor(i){t(this,i),l(this),this.errors=c(this),hi(this,(t=>{this.stores||(this.stores=u(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)}};Ki.style=":host{display:none}";const Qi=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(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)}};Qi.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 Zi=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(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 ts(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return a.global.fontSizePx}function is(t,i){var s;return{version:bi,tag:t.localName,id:ci(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(t,i),em:{fontSizePx:ts(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:ai(t)}}Zi.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 ss="data-bn-baseline",es=t=>Math.round(100*t)/100;function ns(t,i){const s=t.querySelector(`[${ss}]`),e=null!=s?s:t.querySelector('g[id="axis"] line');if(!e)return{};const n=ui(i);return"frame"===e.getAttribute(ss)?function(t,i){const s=i.toLocal(t.getBoundingClientRect());return{x:es(s.x),y:es(s.y+s.height)}}(e,n):function(t,i){const s=i.toLocal(t.getBoundingClientRect());return s.width>=s.height?{x:es(s.x),y:es(s.y+s.height/2)}:{x:es(s.x+s.width/2),y:es(s.y)}}(e,n)}function rs(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?ns(r,t):{}}const os=[["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"]],hs="data-bn-part";function as(t,i){const s={};if(!t)return s;for(const[i,e]of os){const n=t[i];null!=n&&""!==n&&(s[e]=String(n))}return i&&(s[hs]=i),s}function ls(t){const i=t.getAttribute(hs);if(!i)return;const s={part:i};for(const[i,e]of os){const n=t.getAttribute(e);null!=n&&(s[i]=n)}return s}function cs(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 us(t,i){return null==i?{}:t.startsWith("rowGroup")?{rowGroup:String(i)}:t.startsWith("subCategory")?{subCategory:String(i)}:{category:String(i)}}const ds=/^Scenario([1-4])$/,fs=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,vs='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function ps(t){const i=t.getAttribute("data-bn-value");if(null==i||""===i)return;const s=Number(i);return Number.isFinite(s)?s:void 0}function gs(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){const t=ds.exec(null!==(s=e.id)&&void 0!==s?s:"");if(t)return`scenario${t[1]}`;e=e.parentElement}}function ms(t){if(""===t)return;const i=Number(t.split("_")[0]);return Number.isFinite(i)?i:void 0}function bs(t){const i=t.getAttribute("data-bn-index");return null===i?void 0:Number(i)}function ys(t,i){var s;return(null!==(s=t.getAttribute("class"))&&void 0!==s?s:"").split(/\s+/).includes(i)}function ws(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:li(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(vs).forEach((t=>{const i=fs.exec(t.id);i&&t.querySelector("rect")&&s.add(i[1])})),s.size}(f),h.baseline=ns(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:gs(r,t),index:null!==(h=ms(r.id))&&void 0!==h?h:o,rect:li(r,s),point:ls(r),value:ps(r)};e.push(a)})),t.querySelectorAll(vs).forEach((t=>{var r,o,h;const a=fs.exec(t.id);if(!a||!t.querySelector("rect"))return;n.add(t);const l=ls(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:li(t,s),point:l,value:ps(t)};e.push(c)})),["DATA","SCENARIO"].forEach((r=>{t.querySelectorAll(`g[id$="_${r}_Label"]`).forEach(((t,o)=>{var h,a,l,c;if(ys(t,"hide"))return;const u=null!==(a=null===(h=t.textContent)||void 0===h?void 0:h.trim())&&void 0!==a?a:"";if(!u)return;n.add(t);const d={kind:"label",id:t.id,role:"DATA"===r?"data":"scenario",text:u,segment:i,index:null!==(l=ms(t.id))&&void 0!==l?l:o,rect:li(null!==(c=t.querySelector("text"))&&void 0!==c?c:t,s),point:ls(t)};e.push(d)}))})),t.querySelectorAll("[data-bn-part]").forEach(((r,o)=>{var h,a,l,c;if(n.has(r))return;const u=ls(r),d=null!==(h=bs(r))&&void 0!==h?h:function(t,i){var s;for(let e=t;e&&e!==i;e=e.parentElement){const t=ms(null!==(s=e.id)&&void 0!==s?s:"");if(void 0!==t)return t}}(r,t);if("element"===u.part){const t={kind:"point",series:u.scenario,index:null!=d?d:o,rect:li(r,s),point:u};return void e.push(t)}const f={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:d,rect:li(null!==(c=r.querySelector("text"))&&void 0!==c?c:r,s),point:u};e.push(f)})),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=li(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(ys(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:ys(n,"categories")?"title":"category",text:h,segment:i,rect:li(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:li(t,e)})}})),"full"===n&&(h.elements=a),h}function xs(t,i,s,e,n,r){var o,h,a,l;const c={version:bi,tag:t.localName,id:ci(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:li(t,n),em:e,regions:[],metadata:{title:s},diagnostics:ai(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:li(u,n)}),c.metadata.pointCount=u.querySelectorAll("circle, ellipse").length,c.baseline=ns(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:li(t,i),point:ls(t)};s.push(n)})),t.querySelectorAll('rect[data-bn-part="element"]').forEach(((t,e)=>{var n;const r=ls(t),o={kind:"bar",segment:"base",scenario:null==r?void 0:r.scenario,index:null!==(n=bs(t))&&void 0!==n?n:e,rect:li(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:li(t,i),point:ls(t)};s.push(o)})),s}(u,n))),c}function Ss(t,i,s){var e,n,r,o,h;const a="WARN_overflow",l=Xt(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=Jt(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 $s(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 Ms=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])},c=()=>{const i=e(t),s=i.getAttribute("ruleset");if(a&&(a.disconnect(),a=null),s&&qt(s)){const e=Kt(i,s);if(r=Qt(e,"ruleset"),e.length>0){a=new MutationObserver((()=>{r=Qt(e,"ruleset"),l(),n(t)}));for(const t of e)a.observe(t,{attributes:!0,attributeFilter:["ruleset"]})}}else r=s},d=new MutationObserver((i=>{i.forEach((i=>{"ruleset"===i.attributeName&&(c(),l(),n(t))}))})),p=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=u(h),o=s.ruleSets.state._system,d.observe(h,{attributes:!0,attributeFilter:["ruleset"]}),c(),l(),i=s.ruleSets.on("set",(i=>{i!==r&&"_default"!==i||(c(),l(),n(e(t)))})),f(p,t)};const g=t.disconnectedCallback;return t.disconnectedCallback=()=>{d.disconnect(),a&&(a.disconnect(),a=null),f(i),v(e(t)),f(g,t)},(t="all")=>"user"===t?h:o},_s=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=u(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))})),f(o,t)};const h=t.disconnectedCallback;t.disconnectedCallback=()=>{f(i),v(e(t)),f(h,t)}};function ks(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 Ns(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 Rs=["measure","label","unit","min","max","refLine","highlight"];function Ls(t){const i=[],s=Ns(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Os(t,Rs),invalidFields:i};const e={measure:s.trim()};return e.label=Ns(t,"label",i),e.unit=Ns(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,Rs),invalidFields:i}}const Ts=["measure","label","unit","group"];function Es(t){const i=[],s=Ns(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Os(t,Ts),invalidFields:i};const e={measure:s.trim()};return e.label=Ns(t,"label",i),e.unit=Ns(t,"unit",i),e.group=Ns(t,"group",i),{config:e,unknownKeys:Os(t,Ts),invalidFields:i}}const Cs=["measure"];function Ps(t){const i=[],s=Ns(t,"measure",i);return void 0===s||""===s.trim()?(i.push("measure"),{config:null,unknownKeys:Os(t,Cs),invalidFields:i}):{config:{measure:s.trim()},unknownKeys:Os(t,Cs),invalidFields:i}}const Ws=["values","label","unit","highlight"];function Ds(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,Ws),invalidFields:i};const e={values:s};if(e.label=Ns(t,"label",i),e.unit=Ns(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,Ws),invalidFields:i}}const zs=["points","values","max"];function Us(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,zs),invalidFields:s}}const Fs=["level","columns"];function Gs(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,Fs),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,Fs),invalidFields:i}}const js=["show","position"];function Is(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,js),invalidFields:i}}function Bs(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 Ys={rowGroup:0,category:1,subCategory:2},Hs=["ac","pp","fc","pl"],Vs=class{validateFilter(t){const i="ERR_filter";p(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=>Ls(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>Ls(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>Es(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>Ps(t)))}validateCompareWith(t){const i="WARN_compareWith";L(t)||Hs.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' - expected ${Hs.join("/")}; ignored.`})}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];L(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"];L(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=>Gs(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>Us(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>Is(t)))}validateAspect(t){const i="WARN_aspect";L(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";T(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(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-bubble-renderer");const{mode:t}=ii(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}=Xt(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(){Ss(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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}=ks(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:"";C(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}=ks(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}=ks(i,"measure");if(e||null===s)return null;const{config:n}=Ls(s);return null!==n&&C(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}=ks(this.size,"measure");if(i||null===t)return null;const{config:s}=Es(t);return null!==s&&C(s.measure)?s:null}prepareShare(){const{data:t,parseError:i}=ks(this.share,"measure");if(i||null===t)return null;const{config:s}=Ps(t);return null!==s&&C(s.measure)?s:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return Hs.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:Us(i,t).config}prepareLegend(){const{data:t,parseError:i}=ks(this.legend,null);return i||null===t?{show:!0,position:"right"}:Is(t).config}prepareFacet(){const{data:t,parseError:i}=ks(this.facet,null);return i||null===t?null:Gs(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=P(i);null!==t&&("scenario"===t.kind?s.add(W(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&&Ys[o]>=Ys[r]&&(a=`series '${o}' vs point '${r}'`),null!==h){const t=null!=o?o:r;Ys[h]>=Ys[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(g.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 rs(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=di(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 xs(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=P(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=P(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=Xt(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}]}}};Vs.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 Xs{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 Js(t,i,s){return"op"!==t&&"opinv"!==t?t:"op"===t!=(!s&&"-"===i)?"pos":"neg"}function qs(t){const i=[];for(const s of t){const t=new Xs(s);for(const s of t.isValid?[t.base,t.delta]:[])i.includes(s)||i.push(s)}return i}const Ks=["ac","pp","fc","pl"],Qs={10:"ac",20:"pp",30:"fc",50:"pl"};function Zs(t){var i;return null!==(i=Qs[t])&&void 0!==i?i:"ac"}function te(t,i){const s=Ks.map((t=>Zs(i.getScenarioColorIndex(`${t}1`))));if(s.every(((t,i)=>t===Ks[i])))return t;const e=Object.assign(Object.create(Object.getPrototypeOf(t)),t);return Ks.forEach(((i,n)=>{e[i]=t[s[n]]})),e}function ie(t){var i,s;const e=new Map;for(const n of Ks){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 se{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([m,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 Xs(t);return i.isValid?i.type+i.delta:t}}class ee{constructor(){this.font="16px Arial",this.family="Arial",this.size=16,this.color="#000000",this.background="#ffffff",this.leading=1.8}}class ne{adapt(t){const i=new ee;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 ee}}let re=class{constructor(){this.top=10,this.left=10,this.right=10,this.bottom=10}};class oe{adapt(t){const i=new re;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 re}}function he(t){return"fc"===t||"hatched"===t?"hatched":"solid"===t||"outlined"===t?t:void 0}class ae{constructor(t="#000000",i="#000000",s=.1){this.stroke=t,this.fill=i,this.width=s}}class le{adapt(t){const i=new ae(t.stroke,t.fill,t.width);return i.fillpattern=he(t.fillpattern),"outlined"===i.fillpattern&&(i.fill="transparent"),R.isString(t.dasharray)&&(i.dasharray=t.dasharray),i}default(){return new ae("#000000","#000000",.3)}defaultAC(){return new ae("#000000","#000000",.3)}defaultFC(){const t=new ae("#000000","#000000",.3);return t.dasharray="10 5 5 5",t.fillpattern="hatched",t}defaultPP(){return new ae("#999999","#999999",.3)}defaultPL(){return new ae("#000000","#ffffff",.3)}defaultPos(){return new ae("#00ff00","#00ff00",.3)}defaultNeg(){return new ae("#ff0000","#ff0000",.3)}defaultNeu(){return new ae("#999999","#999999",.3)}}class ce{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 ue{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new ce(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 ce(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL())}}class de{constructor(t,i,s,e){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.padding=e,this.seriesColors=[...b],this.locale="de"}}class fe{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 de(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class ve{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 pe{adapt(t){const i=new ve;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 ve}}var ge=Object.create,me=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyNames,we=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,Se=(t,i)=>()=>(i||(t((i={exports:{}}).exports,i),t=null),i.exports),$e=t=>{let i={};for(var s in t)me(i,s,{get:t[s],enumerable:!0});return me(i,Symbol.toStringTag,{value:"Module"}),i},Me=(t,i,s)=>(s=null!=t?ge(we(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var n,r=ye(i),o=0,h=r.length;o<h;o++)xe.call(t,n=r[o])||undefined===n||me(t,n,{get:(t=>i[t]).bind(null,n),enumerable:!(e=be(i,n))||e.enumerable});return t})(me(s,"default",{value:t,enumerable:!0}),t));const _e={},ke=[];function Oe(t,i){if(Array.isArray(t))for(const s of t)Oe(s,i);else if("object"!=typeof t)Ae(Object.getOwnPropertyNames(i)),_e[t]=Object.assign(_e[t]||{},i);else for(const i in t)Oe(i,t[i])}function Ne(t){return _e[t]||{}}function Ae(t){ke.push(...t)}var Re=Se(((t,i)=>{i.exports=function(t){try{return!!t()}catch(t){return!0}}})),Le=Se(((t,i)=>{var s=Re();i.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))})),Te=Se(((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)}}})),Ee=Se(((t,i)=>{var s=Te();i.exports=s({}.isPrototypeOf)})),Ce=Se(((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")()})),Pe=Se(((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)})})),We=Se(((t,i)=>{var s=Te(),e=s({}.toString),n=s("".slice);i.exports=function(t){return n(e(t),8,-1)}})),De=Se(((t,i)=>{var s=We(),e=Te();i.exports=function(t){if("Function"===s(t))return e(t)}})),ze=Se(((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}})),Ue=Se(((t,i)=>{var s=Re();i.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Fe=Se(((t,i)=>{var s=Le(),e=Function.prototype.call;i.exports=s?e.bind(e):function(){return e.apply(e,arguments)}})),Ge=Se((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})),je=Se(((t,i)=>{i.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}})),Ie=Se(((t,i)=>{var s=Te(),e=Re(),n=We(),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})),Be=Se(((t,i)=>{i.exports=function(t){return null==t}})),Ye=Se(((t,i)=>{var s=Be(),e=TypeError;i.exports=function(t){if(s(t))throw new e("Can't call method on "+t);return t}})),He=Se(((t,i)=>{var s=Ie(),e=Ye();i.exports=function(t){return s(e(t))}})),Ve=Se(((t,i)=>{var s=ze();i.exports=function(t){return"object"==typeof t?null!==t:s(t)}})),Xe=Se(((t,i)=>{i.exports={}})),Je=Se(((t,i)=>{var s=Xe(),e=Ce(),n=ze(),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]}})),qe=Se(((t,i)=>{var s=Ce().navigator,e=s&&s.userAgent;i.exports=e?String(e):""})),Ke=Se(((t,i)=>{var s,e,n=Ce(),r=qe(),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})),Qe=Se(((t,i)=>{var s=Ke(),e=Re(),n=Ce().String;i.exports=!!Object.getOwnPropertySymbols&&!e((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))})),Ze=Se(((t,i)=>{var s=Qe();i.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),tn=Se(((t,i)=>{var s=Je(),e=ze(),n=Ee(),r=Ze(),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))}})),sn=Se(((t,i)=>{var s=String;i.exports=function(t){try{return s(t)}catch(t){return"Object"}}})),en=Se(((t,i)=>{var s=ze(),e=sn(),n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not a function")}})),nn=Se(((t,i)=>{var s=en(),e=Be();i.exports=function(t,i){var n=t[i];return e(n)?void 0:s(n)}})),rn=Se(((t,i)=>{var s=Fe(),e=ze(),n=Ve(),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")}})),on=Se(((t,i)=>{i.exports=!0})),hn=Se(((t,i)=>{var s=Ce(),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}})),an=Se(((t,i)=>{var s=on(),e=Ce(),n=hn(),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"})})),ln=Se(((t,i)=>{var s=an();i.exports=function(t,i){return s[t]||(s[t]=i||{})}})),cn=Se(((t,i)=>{var s=Ye(),e=Object;i.exports=function(t){return e(s(t))}})),un=Se(((t,i)=>{var s=Te(),e=cn(),n=s({}.hasOwnProperty);i.exports=Object.hasOwn||function(t,i){return n(e(t),i)}})),dn=Se(((t,i)=>{var s=Te(),e=0,n=Math.random(),r=s(1.1.toString);i.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+r(++e+n,36)}})),fn=Se(((t,i)=>{var s=Ce(),e=ln(),n=un(),r=dn(),o=Qe(),h=Ze(),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]}})),vn=Se(((t,i)=>{var s=Fe(),e=Ve(),n=tn(),r=nn(),o=rn(),h=fn(),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)}})),pn=Se(((t,i)=>{var s=vn(),e=tn();i.exports=function(t){var i=s(t,"string");return e(i)?i:i+""}})),gn=Se(((t,i)=>{var s=Ce(),e=Ve(),n=s.document,r=e(n)&&e(n.createElement);i.exports=function(t){return r?n.createElement(t):{}}})),mn=Se(((t,i)=>{var s=Ue(),e=Re(),n=gn();i.exports=!s&&!e((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))})),bn=Se((t=>{var i=Ue(),s=Fe(),e=Ge(),n=je(),r=He(),o=pn(),h=un(),a=mn(),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])}})),yn=Se(((t,i)=>{var s=Re(),e=ze(),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})),wn=Se(((t,i)=>{var s=De(),e=en(),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)}}})),xn=Se(((t,i)=>{var s=Ue(),e=Re();i.exports=s&&e((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),Sn=Se(((t,i)=>{var s=Ve(),e=String,n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not an object")}})),$n=Se((t=>{var i=Ue(),s=mn(),e=xn(),n=Sn(),r=pn(),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}})),Mn=Se(((t,i)=>{var s=Ue(),e=$n(),n=je();i.exports=s?function(t,i,s){return e.f(t,i,n(1,s))}:function(t,i,s){return t[i]=s,t}})),_n=Se(((t,i)=>{var s=Ce(),e=Pe(),n=De(),r=ze(),o=bn().f,h=yn(),a=Xe(),l=wn(),c=Mn(),u=un();an();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,k=S?a:a[x]||c(a,x,{})[x],O=k.prototype;for(p in i)f=!(e=h(S?p:x+($?".":"#")+p,t.forced))&&_&&u(_,p),m=k[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(k,p,y),M&&(u(a,v=x+"Prototype")||c(a,v,{}),c(a[v],p,g),t.real&&O&&(e||!O[p])&&c(O,p,g)))}})),kn=Se(((t,i)=>{var s=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(t){var i=+t;return(i>0?e:s)(i)}})),On=Se(((t,i)=>{var s=kn();i.exports=function(t){var i=+t;return i!=i||0===i?0:s(i)}})),Nn=Se(((t,i)=>{var s=On(),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)}})),An=Se(((t,i)=>{var s=On(),e=Math.min;i.exports=function(t){var i=s(t);return i>0?e(i,9007199254740991):0}})),Rn=Se(((t,i)=>{var s=An();i.exports=function(t){return s(t.length)}})),Ln=Se(((t,i)=>{var s=He(),e=Nn(),n=Rn(),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)}})),Tn=Se(((t,i)=>{i.exports=function(){}})),En=Se((()=>{var t=_n(),i=Ln().includes,s=Re(),e=Tn(),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")})),Cn=Se(((t,i)=>{var s=Ce(),e=Xe();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]}})),Pn=Se(((t,i)=>{En();var s=Cn();i.exports=s("Array","includes")})),Wn=Se(((t,i)=>{var s=Ve(),e=We(),n=fn()("match");i.exports=function(t){var i;return s(t)&&(void 0!==(i=t[n])?!!i:"RegExp"===e(t))}})),Dn=Se(((t,i)=>{var s=Wn(),e=TypeError;i.exports=function(t){if(s(t))throw new e("The method doesn't accept regular expressions");return t}})),zn=Se(((t,i)=>{var s={};s[fn()("toStringTag")]="z",i.exports="[object z]"===String(s)})),Un=Se(((t,i)=>{var s=zn(),e=ze(),n=We(),r=fn()("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}})),Fn=Se(((t,i)=>{var s=Un(),e=String;i.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return e(t)}})),Gn=Se(((t,i)=>{var s=fn()("match");i.exports=function(t){var i=/./;try{"/./"[t](i)}catch(e){try{return i[s]=!1,"/./"[t](i)}catch(t){}}return!1}})),jn=Se((()=>{var t=_n(),i=Te(),s=Dn(),e=Ye(),n=Fn(),r=Gn(),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)}})})),In=Se(((t,i)=>{jn();var s=Cn();i.exports=s("String","includes")})),Bn=Se(((t,i)=>{var s=Ee(),e=Pn(),n=In(),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}})),Yn=Me(Se(((t,i)=>{var s=Bn();i.exports=s}))());function Hn(t,i){let s;const e=t.length,n=[];for(s=0;s<e;s++)n.push(i(t[s]));return n}function Vn(t){return t%360*Math.PI/180}function Xn(t){return t.replace(/([A-Z])/g,(function(t,i){return"-"+i.toLowerCase()}))}function Jn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qn(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 Kn(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,Yn.default)(e).call(e,"left")?h:(0,Yn.default)(e).call(e,"right")?h+s:h+s/2),o&&(n=(0,Yn.default)(n).call(n,"top")?a:(0,Yn.default)(n).call(n,"bottom")?a+t:a+t/2)}return[e,n]}const Qn=new Set(["desc","metadata","title"]),Zn=t=>Qn.has(t.nodeName),tr="http://www.w3.org/2000/svg",ir="http://www.w3.org/2000/xmlns/",sr="http://www.w3.org/1999/xlink",er={window:"undefined"==typeof window?null:window,document:"undefined"==typeof document?null:document};var nr=class{};const rr={},or="___SYMBOL___ROOT___";function hr(t,i=tr){return er.document.createElementNS(i,t)}function ar(t,i=!1){if(t instanceof nr)return t;if("object"==typeof t)return ur(t);if(null==t)return new rr[or];if("string"==typeof t&&"<"!==t.trim().charAt(0))return ur(er.document.querySelector(t));const s=i?er.document.createElement("div"):hr("svg");return s.innerHTML=t.trim(),t=ur(s.firstElementChild),s.removeChild(s.firstElementChild),t}function lr(t,i){return i&&(i instanceof er.window.Node||i.ownerDocument&&i instanceof i.ownerDocument.defaultView.Node)?i:hr(t)}function cr(t){if(!t)return null;if(t.instance instanceof nr)return t.instance;if("#document-fragment"===t.nodeName)return new rr.Fragment(t);let i=Jn(t.nodeName||"Dom");return"LinearGradient"===i||"RadialGradient"===i?i="Gradient":rr[i]||(i="Dom"),new rr[i](t)}let ur=cr;function dr(t,i=t.name,s=!1){return rr[i]=t,s&&(rr[or]=t),Ae(Object.getOwnPropertyNames(t.prototype)),t}let fr=1e3;function vr(t){return"Svgjs"+Jn(t)+fr++}function pr(t){for(let i=t.children.length-1;i>=0;i--)pr(t.children[i]);return t.id?(t.id=vr(t.nodeName),t):t}function gr(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 mr(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)}}Oe("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=ar(t)).remove();const i=this.position();return this.parent().add(t,i),this},after:function(t){(t=ar(t)).remove();const i=this.position();return this.parent().add(t,i+1),this},insertBefore:function(t){return(t=ar(t)).before(this),this},insertAfter:function(t){return(t=ar(t)).after(this),this}});const br=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,yr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,wr=/rgb\((\d+),(\d+),(\d+)\)/,xr=/^(#[^\s]+)$/,Sr=/\)\s*,?\s*/,$r=/\s/g,Mr=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,_r=/^rgb\(/,kr=/^(\s+)?$/,Or=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Nr=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,Ar=/[\s,]+/,Rr=/[MLHVCSQTAZ]/i;Oe("Dom",{classes:function(){const t=this.attr("class");return null==t?[]:t.trim().split(Ar)},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:Xn(t);function Tr(t){const i=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===i.length?"0"+i:i}function Er(t,i){for(let s=i.length;s--;)if(null==t[i[s]])return!1;return!0}function Cr(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}Oe("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]||kr.test(t[i])?"":t[i])}return 2===arguments.length&&this.node.style.setProperty(Lr(t),null==i||kr.test(i)?"":i),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),Oe("Dom",{data:function(t,i,s){if(null==t)return this.data(Hn(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}}),Oe("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 Pr=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&&(Mr.test(t)||_r.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=Er(t,"rgb")?{_a:t.r,_b:t.g,_c:t.b,_d:0,space:"rgb"}:Er(t,"xyz")?{_a:t.x,_b:t.y,_c:t.z,_d:0,space:"xyz"}:Er(t,"hsl")?{_a:t.h,_b:t.s,_c:t.l,_d:0,space:"hsl"}:Er(t,"lab")?{_a:t.l,_b:t.a,_c:t.b,_d:0,space:"lab"}:Er(t,"lch")?{_a:t.l,_b:t.c,_c:t.h,_d:0,space:"lch"}:Er(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(_r.test(t)){const i=t.replace($r,""),[s,e,n]=wr.exec(i).slice(1,4).map((t=>parseInt(t)));Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}else{if(!Mr.test(t))throw Error("Unsupported string format, can't construct Color");{const i=t=>parseInt(t,16),[,s,e,n]=yr.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*Cr(r,n,i+1/3),h=255*Cr(r,n,i),a=255*Cr(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(Tr);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))))}},Wr=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){zr.isMatrixLike(t)||(t=new zr(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 Dr(t,i){return Math.abs(i-t)<1e-6}var zr=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 Wr(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),u=c.x,d=c.y,f=new Wr(t.position??t.px??t.positionX??NaN,t.py??t.positionY??NaN),v=f.x,p=f.y,g=new Wr(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=g.x,b=g.y,y=new Wr(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 Dr(this.a,s.a)&&Dr(this.b,s.b)&&Dr(this.c,s.c)&&Dr(this.d,s.d)&&Dr(this.e,s.e)&&Dr(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 co?i.matrixify():"string"==typeof i?t.fromArray(i.split(Ar).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=Vn(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=Vn(t),i=Vn(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 Wr(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 Wr(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 Ur(){if(!Ur.nodes||Ur.nodes.svg.node.ownerDocument!==er.document){const t=ar().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"),Ur.nodes={svg:t,path:t.path().node}}return Ur.nodes.svg.node.parentNode||Ur.nodes.svg.addTo(er.document.body||er.document.documentElement),Ur.nodes}function Fr(t){return!(t.width||t.height||t.x||t.y)}dr(zr,"Matrix");var Gr=class t{constructor(...t){this.init(...t)}addOffset(){return this.x+=er.window.pageXOffset,this.y+=er.window.pageYOffset,new t(this)}init(t){return t="string"==typeof t?t.split(Ar).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 Fr(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 zr||(i=new zr(i));let s=1/0,e=-1/0,n=1/0,r=-1/0;return[new Wr(this.x,this.y),new Wr(this.x2,this.y),new Wr(this.x,this.y2),new Wr(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 jr(t,i,s){let e;try{if(e=i(t.node),Fr(e)&&(n=t.node)!==er.document&&!(er.document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===er.document}).call(er.document.documentElement,n))throw new Error("Element not in the dom")}catch(i){e=s(t)}var n;return e}Oe({viewbox:{viewbox(t,i,s,e){return null==t?new Gr(this.attr("viewBox")):this.attr("viewBox",new Gr(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 Wr(s/2/r+n.x,e/2/o+n.y);const l=new Gr(n).transform(new zr({scale:a,origin:i}));return this.viewbox(l)}}}),dr(Gr,"Box");var Ir=class extends Array{constructor(t=[],...i){if(super(t,...i),"number"==typeof t)return this;this.length=0,this.push(...t)}};gr([Ir],{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 Br=["toArray","constructor","each"];function Yr(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(xr);return e?e[1].slice(1):null}function Hr(t,i){const s=`#${er.window.CSS.escape(i)}`;return 1===t.nodeType&&t.matches(s)?t:t.querySelector(s)}function Vr(t,i,s=`[${i}]`){const e=t.getAttribute("id"),n=t.getRootNode();if(!e||Hr(n,e)!==t)return new Ir;const r=[];1===n.nodeType&&n.matches(s)&&Yr(n.getAttribute(i))===e&&r.push(cr(n));for(const t of n.querySelectorAll(s))Yr(t.getAttribute(i))===e&&r.push(cr(t));return new Ir(r)}Ir.extend=function(t){t=t.reduce(((t,i)=>((0,Yn.default)(Br).call(Br,i)||"_"===i[0]||(i in Array.prototype&&(t["$"+i]=Array.prototype[i]),t[i]=function(...t){return this.each(i,...t)}),t)),{}),gr([Ir],t)};let Xr=0;const Jr=new WeakMap,qr=new WeakMap,Kr=()=>Object.create(null);function Qr(t){const i=t.getEventHolder();let s=Jr.get(i);return s||(s=Kr(),Jr.set(i,s)),s}function Zr(t){return t.getEventTarget()}function to(t,i,s,e,n){const r=s.bind(e||t),o=n||!1,h=ar(t),a=Qr(h),l=Zr(h);i=Array.isArray(i)?i:i.split(Ar);let c=qr.get(s);c||(c=++Xr,qr.set(s,c)),i.forEach((function(t){const i=t.split(".")[0],s=t.split(".")[1]||"*";a[i]=a[i]||Kr(),a[i][s]=a[i][s]||Kr(),a[i][s][c]=a[i][s][c]||[],a[i][s][c].push({listener:r,options:o}),l.addEventListener(i,r,o)}))}function io(t,i,s,e){const n=ar(t),r=Qr(n),o=Zr(n);("function"!=typeof s||(s=qr.get(s)))&&(i=Array.isArray(i)?i:(i||"").split(Ar)).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])io(o,[i,h].join("."),l);delete r[i][h]}}else if(h)for(t in r)for(a in r[t])h===a&&io(o,[t,h].join("."));else if(i){if(r[i]){for(a in r[i])io(o,[i,a].join("."));delete r[i]}}else{for(t in r)io(o,t);!function(t){Jr.delete(t.getEventHolder())}(n)}}))}var so=class extends nr{addEventListener(){}dispatch(t,i,s){return function(t,i,s,e){const n=Zr(t);return i instanceof er.window.Event||(i=new er.window.CustomEvent(i,{detail:s,cancelable:!0,...e})),n.dispatchEvent(i),i}(this,t,i,s)}dispatchEvent(t){const i=Qr(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 io(this,t,i,s),this}on(t,i,s,e){return to(this,t,i,s,e),this}removeEventListener(){}};function eo(){}dr(so,"EventTarget");const no={"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 ro=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(Ar).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}},oo=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(br))&&(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 ho=new Set(["fill","stroke","color","bgcolor","stop-color","flood-color","lighting-color"]),ao=[];var lo=class t extends so{constructor(t,i){super(),this.node=t,this.type=t.nodeName,i&&t!==i&&this.attr(i)}add(t,i){return(t=ar(t)).removeNamespace&&this.node instanceof er.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 ar(t).put(this,i)}children(){return new Ir(Hn(this.node.children,(function(t){return cr(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=pr(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(hr(i),s))}first(){return cr(this.node.firstChild)}get(t){return cr(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=vr(this.type)),this.attr("id",t)}index(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}last(){return cr(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=cr(i.node.parentNode),!t)return i;do{if("string"==typeof t?i.matches(t):i instanceof t)return i}while(i=cr(i.node.parentNode));return i}put(t,i){return t=ar(t),this.add(t,i),t}putIn(t,i){return ar(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=ar(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,tr)}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=cr(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=hr("wrapper",s),n=er.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)}};gr(lo,{attr:function(t,i,s){if(null==t){t={},i=this.node.attributes;for(const s of i)t[s.nodeName]=Or.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))?no[t]:Or.test(i)?parseFloat(i):i;"number"==typeof(i=ao.reduce(((i,s)=>s(t,i,this)),i))?i=new oo(i):ho.has(t)&&Pr.isColor(i)?i=new Pr(i):i.constructor===Array&&(i=new ro(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 Ir(Hn((i||er.document).querySelectorAll(t),(function(t){return cr(t)})))}(t,this.node)},findOne:function(t){return cr(this.node.querySelector(t))}}),dr(lo,"Dom");var co=class extends lo{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 oo(t).plus(this.x()))}dy(t=0){return this.y(new oo(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&&ar(t).node);const n=new Ir;let r=this;for(;(r=r.parent())&&r.node!==er.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=Yr(i);return s?Hr(t.getRootNode(),s):null}(this.node,t);return i?ar(i):null}root(){const t=this.parent(rr[or]);return t&&t.root()}setData(t){return this.dom=t,this}size(t,i){const s=qn(this,t,i);return this.width(new oo(s.width)).height(new oo(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)}};gr(co,{bbox:function(){const t=jr(this,(t=>t.getBBox()),(t=>{try{const i=t.clone().addTo(Ur().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 Gr(t)},rbox:function(t){const i=jr(this,(t=>t.getBoundingClientRect()),(t=>{throw new Error(`Getting rbox of element "${t.node.nodeName}" is not possible`)})),s=new Gr(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 Wr(t,i).transformO(this.screenCTM().inverseO())},ctm:function(){return new zr(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 zr(i)}return new zr(this.node.getScreenCTM())}catch(t){return console.warn(`Cannot get CTM from SVG node ${this.node.nodeName}. Is the element rendered?`),new zr}}}),dr(co,"Element");const uo={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 Pr||Pr.isRgb(i)||i instanceof co)this.attr(t,i);else for(s=uo[t].length-1;s>=0;s--)null!=i[uo[t][s]]&&this.attr(uo.prefix(t,uo[t][s]),i[uo[t][s]]);return this},Oe(["Element","Runner"],i)})),Oe(["Element","Runner"],{matrix:function(t,i,s,e,n,r){return null==t?new zr(this):this.attr("transform",new zr(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)}}),Oe("radius",{radius:function(t,i=t){return"radialGradient"===(this._element||this).type?this.attr("r",new oo(t)):this.rx(t).ry(i)}}),Oe("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new Wr(this.node.getPointAtLength(t))}}),Oe(["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)}}),Oe("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}),{})),Oe("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(Sr).slice(0,-1).map((function(t){const i=t.trim().split("(");return[i[0].trim(),i[1].split(Ar).map((function(t){return parseFloat(t)}))]})).reverse().reduce((function(t,i){return"matrix"===i[0]?t.lmultiply(zr.fromArray(i[1])):t[i[0]].apply(t,i[1])}),new zr)},toParent:function(t,i){if(this===t)return this;if(Zn(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 zr(this).decompose();return null==t?i:i[t]}zr.isMatrixLike(t)||(t={...t,origin:Kn(t,this)});const s=new zr(!0===i?this:i||!1).transform(t);return this.attr("transform",s)}});var fo=class t extends co{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()}};dr(fo,"Container");var vo=class extends fo{constructor(t,i=t){super(lr("defs",t),i)}flatten(){return this}ungroup(){return this}};dr(vo,"Defs");var po=class extends co{};dr(po,"Shape");var go=$e({cx:()=>xo,cy:()=>So,height:()=>Mo,rx:()=>mo,ry:()=>bo,width:()=>$o,x:()=>yo,y:()=>wo});function mo(t){return this.attr("rx",t)}function bo(t){return this.attr("ry",t)}function yo(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function wo(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function xo(t){return this.attr("cx",t)}function So(t){return this.attr("cy",t)}function $o(t){return null==t?2*this.rx():this.rx(new oo(t).divide(2))}function Mo(t){return null==t?2*this.ry():this.ry(new oo(t).divide(2))}var _o=class extends po{constructor(t,i=t){super(lr("ellipse",t),i)}size(t,i){const s=qn(this,t,i);return this.rx(new oo(s.width).divide(2)).ry(new oo(s.height).divide(2))}};gr(_o,go),Oe("Container",{ellipse:mr((function(t=0,i=t){return this.put(new _o).size(t,i).move(0,0)}))}),dr(_o,"Ellipse");var ko=class extends lo{constructor(t=er.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 lo(hr("wrapper",s));return t.add(this.node.cloneNode(!0)),t.xml(!1,s)}return super.xml(t,!1,s)}};dr(ko,"Fragment");var Oo=$e({from:()=>No,to:()=>Ao});function No(t,i){return this.attr("radialGradient"===(this._element||this).type?{fx:new oo(t),fy:new oo(i)}:{x1:new oo(t),y1:new oo(i)})}function Ao(t,i){return this.attr("radialGradient"===(this._element||this).type?{cx:new oo(t),cy:new oo(i)}:{x2:new oo(t),y2:new oo(i)})}var Ro=class extends fo{constructor(t,i){super(lr(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 Gr}targets(){return Vr(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()+")"}};gr(Ro,Oo),Oe({Container:{gradient(...t){return this.defs().gradient(...t)}},Defs:{gradient:mr((function(t,i){return this.put(new Ro(t)).update(i)}))}}),dr(Ro,"Gradient");var Lo=class extends fo{constructor(t,i=t){super(lr("pattern",t),i)}attr(t,i,s){return"transform"===t&&(t="patternTransform"),super.attr(t,i,s)}bbox(){return new Gr}targets(){return Vr(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()+")"}};Oe({Container:{pattern(...t){return this.defs().pattern(...t)}},Defs:{pattern:mr((function(t,i,s){return this.put(new Lo).update(s).attr({x:0,y:0,width:t,height:i,patternUnits:"userSpaceOnUse"})}))}}),dr(Lo,"Pattern");var To=class extends po{constructor(t,i=t){super(lr("image",t),i)}load(t,i){if(!t)return this;const s=new er.window.Image;return to(s,"load",(function(t){const e=this.parent(Lo);0===this.width()&&0===this.height()&&this.size(s.width,s.height),e instanceof Lo&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,t)}),this),to(s,"load error",(function(){io(s)})),this.attr("href",s.src=t,sr)}};ao.push((function(t,i,s){return"fill"!==t&&"stroke"!==t||Nr.test(i)&&(i=s.root().defs().image(i)),i instanceof To&&(i=s.root().defs().pattern(0,0,(t=>{t.add(i)}))),i})),Oe({Container:{image:mr((function(t,i){return this.put(new To).size(0,0).load(t,i)}))}}),dr(To,"Image");var Eo=class extends ro{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 Gr(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(Ar).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){zr.isMatrixLike(t)||(t=new zr(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}},Co=$e({MorphArray:()=>Po,height:()=>Uo,width:()=>zo,x:()=>Wo,y:()=>Do});const Po=Eo;function Wo(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}function Do(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}function zo(t){const i=this.bbox();return null==t?i.width:this.size(t,i.height)}function Uo(t){const i=this.bbox();return null==t?i.height:this.size(i.width,t)}var Fo=class extends po{constructor(t,i=t){super(lr("line",t),i)}array(){return new Eo([[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 Eo(t).toLine(),this.attr(t))}size(t,i){const s=qn(this,t,i);return this.attr(this.array().size(s.width,s.height).toLine())}};gr(Fo,Co),Oe({Container:{line:mr((function(...t){return Fo.prototype.plot.apply(this.put(new Fo),null!=t[0]?t:[0,0,0,0])}))}}),dr(Fo,"Line");var Go=class extends fo{constructor(t,i=t){super(lr("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 jo(t,i){return function(s){return null==s?this[t]:(this[t]=s,i&&i.call(this),this)}}Oe({Container:{marker(...t){return this.defs().marker(...t)}},Defs:{marker:mr((function(t,i,s){return this.put(new Go).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 Go?arguments[1]:this.defs().marker(i,s,e),this.attr(n,t)}}}),dr(Go,"Marker");const Io={"-":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 Bo=class{done(){return!1}},Yo=class extends Bo{constructor(t=">"){super(),this.ease=Io[t]||t}step(t,i,s){return"number"!=typeof t?s<1?t:i:t+(i-t)*this.ease(s)}},Ho=class extends Bo{constructor(t){super(),this.stepper=t}done(t){return t.done}step(t,i,s,e){return this.stepper(t,i,s,e)}};function Vo(){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}gr(class extends Ho{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:jo("_duration",Vo),overshoot:jo("_overshoot",Vo)}),gr(class extends Ho{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:jo("_windup"),p:jo("P"),i:jo("I"),d:jo("D")});const Xo={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},Jo={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]]}},qo="mlhvqtcsaz".split("");for(let t=0,i=qo.length;t<i;++t)Jo[qo[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 Jo[t](i,s,e)}}(qo[t].toUpperCase());function Ko(t){return t.segment.length&&t.segment.length-1===Xo[t.segment[0].toUpperCase()]}function Qo(t,i){t.inNumber&&Zo(t,!1);const s=Rr.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 Zo(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,Ko(t)&&th(t)}function th(t){t.inSegment=!1,t.absolute&&(t.segment=function(t){return Jo[t.segment[0]](t.segment.slice(1),t.p,t.p0)}(t)),t.segments.push(t.segment)}function ih(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 sh(t){return"E"===t.lastToken.toUpperCase()}const eh=new Set([" ",",","\t","\n","\r","\f"]);var nh=class extends ro{bbox(){return Ur().path.setAttribute("d",this.toString()),new Gr(Ur.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 Wr,p:new Wr};for(;n.lastToken=e,e=t.charAt(s++);)if(n.inSegment||!Qo(n,e))if("."!==e)if(isNaN(parseInt(e)))if(eh.has(e))n.inNumber&&Zo(n,!1);else if("-"!==e&&"+"!==e)if("E"!==e.toUpperCase()){if(Rr.test(e)){if(n.inNumber)Zo(n,!1);else{if(!Ko(n))throw new Error("parser Error");th(n)}--s}}else n.number+=e,n.hasExponent=!0;else{if(n.inNumber&&!sh(n)){Zo(n,!1),--s;continue}n.number+=e,n.inNumber=!0}else{if("0"===n.number||ih(n)){n.inNumber=!0,n.number=e,Zo(n,!0);continue}n.inNumber=!0,n.number+=e}else{if(n.pointSeen||n.hasExponent){Zo(n,!1),--s;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=e}return n.inNumber&&Zo(n,!1),n.inSegment&&Ko(n)&&th(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 rh=t=>{const i=typeof t;return"number"===i?oo:"string"===i?Pr.isColor(t)?Pr:Ar.test(t)?Rr.test(t)?nh:ro:br.test(t)?oo:hh:uh.indexOf(t.constructor)>-1?t.constructor:Array.isArray(t)?ro:"object"===i?ch:hh};var oh=class{constructor(t){this._stepper=t||new Yo("-"),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(rh(t));let i=new this._type(t);return this._type===Pr&&(i=this._to?i[this._to[4]]():this._from?i[this._from[4]]():i),this._type===ch&&(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}},hh=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}},ah=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]}};ah.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};const lh=(t,i)=>t[0]<i[0]?-1:t[0]>i[0]?1:0;var ch=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]===Pr&&t[s+7]!==i[s+7]){const i=t[s+7],e=new Pr(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=rh(t[s]),n=new e(t[s]).toArray();i.push([s,e,n.length,...n])}return i.sort(lh),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 uh=[hh,ah,ch];var dh=class extends po{constructor(t,i=t){super(lr("path",t),i)}array(){return this._array||(this._array=new nh(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 nh(t))}size(t,i){const s=qn(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)}};dh.prototype.MorphArray=nh,Oe({Container:{path:mr((function(t){return this.put(new dh).plot(t||new nh)}))}}),dr(dh,"Path");var fh=$e({array:()=>vh,clear:()=>ph,move:()=>gh,plot:()=>mh,size:()=>bh});function vh(){return this._array||(this._array=new Eo(this.attr("points")))}function ph(){return delete this._array,this}function gh(t,i){return this.attr("points",this.array().move(t,i))}function mh(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new Eo(t))}function bh(t,i){const s=qn(this,t,i);return this.attr("points",this.array().size(s.width,s.height))}var yh=class extends po{constructor(t,i=t){super(lr("polygon",t),i)}};Oe({Container:{polygon:mr((function(t){return this.put(new yh).plot(t||new Eo)}))}}),gr(yh,Co),gr(yh,fh),dr(yh,"Polygon");var wh=class extends po{constructor(t,i=t){super(lr("polyline",t),i)}};Oe({Container:{polyline:mr((function(t){return this.put(new wh).plot(t||new Eo)}))}}),gr(wh,Co),gr(wh,fh),dr(wh,"Polyline");var xh=class extends po{constructor(t,i=t){super(lr("rect",t),i)}};gr(xh,{rx:mo,ry:bo}),Oe({Container:{rect:mr((function(t,i){return this.put(new xh).size(t,i)}))}}),dr(xh,"Rect");var Sh=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 $h={nextDraw:null,frames:new Sh,timeouts:new Sh,immediates:new Sh,timer:()=>er.window.performance||er.window.Date,transforms:[],frame(t){const i=$h.frames.push({run:t});return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),i},timeout(t,i){i=i||0;const s=$h.timer().now()+i,e=$h.timeouts.push({run:t,time:s});return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),e},immediate(t){const i=$h.immediates.push(t);return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),i},cancelFrame(t){null!=t&&$h.frames.remove(t)},clearTimeout(t){null!=t&&$h.timeouts.remove(t)},cancelImmediate(t){null!=t&&$h.immediates.remove(t)},_draw(t){try{let i=null;const s=$h.timeouts.last();for(;(i=$h.timeouts.shift())&&(t>=i.time?i.run():$h.timeouts.push(i),i!==s););let e=null;const n=$h.frames.last();for(;e!==n&&(e=$h.frames.shift());)e.run(t);let r=null;for(;r=$h.immediates.shift();)r()}finally{const t=$h.timeouts.first()||$h.frames.first()||$h.immediates.first();$h.nextDraw=t?er.window.requestAnimationFrame($h._draw):null}}},Mh=function(t){const i=t.start,s=t.runner.duration();return{start:i,duration:s,end:i+s,runner:t.runner}},_h=function(){const t=er.window;return(t.performance||t.Date).now()};var kh=class extends so{constructor(t=_h){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(Mh);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 $h.cancelFrame(this._nextFrame),this._nextFrame=null,t?this._stepImmediate():(this._paused||(this._nextFrame=$h.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)}};Oe({Element:{timeline:function(t){return null==t?(this._timeline=this._timeline||new kh,this._timeline):(this._timeline=t,this)}}});var Oh=class t extends so{constructor(i){super(),this.id=t.id++,i="function"==typeof(i=null==i?400:i)?new Ho(i):i,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof i&&i,this._isDeclarative=i instanceof Ho,this._stepper=this._isDeclarative?i:new Yo,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new zr,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 Bo||(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 zr,this}clearTransformsFromQueue(){var t;this.done&&this._timeline&&(0,Yn.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 Yo(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||eo,runner:i||eo,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 kh||(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 zr,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}};Oh.id=0;var Nh=class{constructor(t=new zr,i=-1,s=!0){this.transforms=t,this.id=i,this.done=s}clearTransformsFromQueue(){}};gr([Oh,Nh],{mergeWith(t){return new Nh(t.transforms.lmultiply(this.transforms),t.id)}});const Ah=(t,i)=>t.lmultiplyO(i),Rh=t=>t.transforms;function Lh(){const t=this._transformationRunners.runners.map(Rh).reduce(Ah,new zr);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}var Th=class{constructor(){this.runners=[],this.ids=[]}add(t){var i;if((0,Yn.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 Nh).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,Yn.default)(i=n._timeline._runnerIds).call(i,n.id)||t._timeline&&(0,Yn.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}};Oe({Element:{animate(t,i,s){const e=Oh.sanitise(t,i,s),n=this.timeline();return new Oh(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(Rh).reduce(Ah,new zr)},_addRunner(t){this._transformationRunners.add(t),$h.cancelImmediate(this._frameId),this._frameId=$h.immediate(Lh.bind(this))},_prepareRunner(){null==this._frameId&&(this._transformationRunners=(new Th).add(new Nh(new zr(this))))}}}),gr(Oh,{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 oh(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,Yn.default)(n).call(n,t))));var e,n;if(s.length&&null!=r.from()){const i=this.element()[t](s),e=new ch(r.from()).valueOf();Object.assign(e,i),r.from(e)}const h=new ch(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 oh(this._stepper).to(new oo(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=zr.isMatrixLike(t);s=null!=t.affine?t.affine:null!=s?s:!e;const n=new oh(this._stepper).type(s?ah:zr);let r,o,h,a,l;return this.queue((function(){o=o||this.element(),r=r||Kn(t,o),l=new zr(i?void 0:o),o._addRunner(this),i||o._clearTransformRunnersBefore(this)}),(function(c){i||this.clearTransform();const{x:u,y:d}=new Wr(r).transform(o._currentTransform(this)),f={...t,origin:[u,d]};!0===f.relative&&delete f.relative;let v=new zr(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 zr(g),this.addTransform(h),o._addRunner(this),n.done()}),(function(i){(i.origin||"center").toString()!==(t.origin||"center").toString()&&(r=Kn(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 oo(i),this._tryRetarget(t,i))return this;const s=new oh(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 oo(t))})),this._rememberMorpher(t,s),this},_queueObject(t,i){if(this._tryRetarget(t,i))return this;const s=new oh(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 oo(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=qn(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 oh(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 Gr(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)}}),gr(Oh,{rx:mo,ry:bo,from:No,to:Ao}),dr(Oh,"Runner");var Eh=class extends fo{constructor(t,i=t){super(lr("svg",t),i),this.namespace()}defs(){return this.isRoot()?cr(this.node.querySelector("defs"))||this.put(new vo):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof er.window.SVGElement)&&"#document-fragment"!==this.node.parentNode.nodeName}namespace(){return this.isRoot()?this.attr({xmlns:tr,version:"1.1"}).attr("xmlns:xlink",sr,ir):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,ir).attr("xmlns:svgjs",null,ir)}root(){return this.isRoot()?this:super.root()}};Oe({Container:{nested:mr((function(){return this.put(new Eh)}))}}),dr(Eh,"Svg",!0);var Ch=class extends fo{constructor(t,i=t){super(lr("symbol",t),i)}};Oe({Container:{symbol:mr((function(){return this.put(new Ch)}))}}),dr(Ch,"Symbol");var Ph=$e({amove:()=>Hh,ax:()=>Bh,ay:()=>Yh,build:()=>Vh,center:()=>Ih,cx:()=>Gh,cy:()=>jh,length:()=>Dh,move:()=>Fh,plain:()=>Wh,x:()=>zh,y:()=>Uh});function Wh(t){return!1===this._build&&this.clear(),this.node.appendChild(er.document.createTextNode(t)),this}function Dh(){return this.node.getComputedTextLength()}function zh(t,i=this.bbox()){return null==t?i.x:this.attr("x",this.attr("x")+t-i.x)}function Uh(t,i=this.bbox()){return null==t?i.y:this.attr("y",this.attr("y")+t-i.y)}function Fh(t,i,s=this.bbox()){return this.x(t,s).y(i,s)}function Gh(t,i=this.bbox()){return null==t?i.cx:this.attr("x",this.attr("x")+t-i.cx)}function jh(t,i=this.bbox()){return null==t?i.cy:this.attr("y",this.attr("y")+t-i.cy)}function Ih(t,i,s=this.bbox()){return this.cx(t,s).cy(i,s)}function Bh(t){return this.attr("x",t)}function Yh(t){return this.attr("y",t)}function Hh(t,i){return this.ax(t).ay(i)}function Vh(t){return this._build=!!t,this}var Xh=class extends po{constructor(t,i=t){super(lr("text",t),i),this.dom.leading=this.dom.leading??new oo(1.3),this._rebuild=!0,this._build=!1}leading(t){return null==t?this.dom.leading:(this.dom.leading=new oo(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(Zn(this.node))return;const n=er.window.getComputedStyle(this.node).getPropertyValue("font-size"),r=s*new oo(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 oo(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||Zn(i[e])?0===e&&(s=e+1):(e!==s&&3!==i[e].nodeType&&!0===cr(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()}};gr(Xh,Ph),Oe({Container:{text:mr((function(t=""){return this.put(new Xh).text(t)})),plain:mr((function(t=""){return this.put(new Xh).plain(t)}))}}),dr(Xh,"Text");var Jh=class extends po{constructor(t,i=t){super(lr("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 Xh))return this;const i=t.index(this),s=er.window.getComputedStyle(this.node).getPropertyValue("font-size"),e=t.dom.leading*new oo(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)}};gr(Jh,Ph),Oe({Tspan:{tspan:mr((function(t=""){const i=new Jh;return this._build||this.clear(),this.put(i).text(t)}))},Text:{newLine:function(t=""){return this.tspan(t).newLine()}}}),dr(Jh,"Tspan");var qh=class extends po{constructor(t,i=t){super(lr("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 oo(t).divide(2))}};gr(qh,{x:yo,y:wo,cx:xo,cy:So,width:$o,height:Mo}),Oe({Container:{circle:mr((function(t=0){return this.put(new qh).size(t).move(0,0)}))}}),dr(qh,"Circle");var Kh=class extends fo{constructor(t,i=t){super(lr("clipPath",t),i)}remove(){return this.targets().forEach((function(t){t.unclip()})),super.remove()}targets(){return Vr(this.node,"clip-path")}};Oe({Container:{clip:mr((function(){return this.defs().put(new Kh)}))},Element:{clipper(){return this.reference("clip-path")},clipWith(t){const i=t instanceof Kh?t:this.parent().clip().add(t);return this.attr("clip-path","url(#"+i.id()+")")},unclip(){return this.attr("clip-path",null)}}}),dr(Kh,"ClipPath");var Qh=class extends co{constructor(t,i=t){super(lr("foreignObject",t),i)}};Oe({Container:{foreignObject:mr((function(t,i){return this.put(new Qh).size(t,i)}))}}),dr(Qh,"ForeignObject");var Zh=$e({dmove:()=>ta,dx:()=>ia,dy:()=>sa,height:()=>ea,move:()=>na,size:()=>ra,width:()=>oa,x:()=>ha,y:()=>aa});function ta(t,i){return this.children().forEach((s=>{let e;try{e=s.node instanceof er.window.SVGSVGElement?new Gr(s.attr(["x","y","width","height"])):s.bbox()}catch(t){return}const n=new zr(s),r=n.translate(t,i).transform(n.inverse()),o=new Wr(e.x,e.y).transform(r);s.dmove(o.x-e.x,o.y-e.y)})),this}function ia(t){return this.dmove(t,0)}function sa(t){return this.dmove(0,t)}function ea(t,i=this.bbox()){return null==t?i.height:this.size(i.width,t,i)}function na(t=0,i=0,s=this.bbox()){return this.dmove(t-s.x,i-s.y)}function ra(t,i,s=this.bbox()){const e=qn(this,t,i,s),n=e.width/s.width,r=e.height/s.height;return this.children().forEach((t=>{const i=new Wr(s).transform(new zr(t).inverse());t.scale(n,r,i.x,i.y)})),this}function oa(t,i=this.bbox()){return null==t?i.width:this.size(t,i.height,i)}function ha(t,i=this.bbox()){return null==t?i.x:this.move(t,i.y,i)}function aa(t,i=this.bbox()){return null==t?i.y:this.move(i.x,t,i)}var la=class extends fo{constructor(t,i=t){super(lr("g",t),i)}};gr(la,Zh),Oe({Container:{group:mr((function(){return this.put(new la)}))}}),dr(la,"G");var ca=class extends fo{constructor(t,i=t){super(lr("a",t),i)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,sr)}};gr(ca,Zh),Oe({Container:{link:mr((function(t){return this.put(new ca).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 ca,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}}}),dr(ca,"A");var ua=class extends fo{constructor(t,i=t){super(lr("mask",t),i)}remove(){return this.targets().forEach((function(t){t.unmask()})),super.remove()}targets(){return Vr(this.node,"mask")}};Oe({Container:{mask:mr((function(){return this.defs().put(new ua)}))},Element:{masker(){return this.reference("mask")},maskWith(t){const i=t instanceof ua?t:this.parent().mask().add(t);return this.attr("mask","url(#"+i.id()+")")},unmask(){return this.attr("mask",null)}}}),dr(ua,"Mask");var da=class extends co{constructor(t,i=t){super(lr("stop",t),i)}update(t){return("number"==typeof t||t instanceof oo)&&(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 oo(t.offset)),this}};Oe({Gradient:{stop:function(t,i,s){return this.put(new da).update(t,i,s)}}}),dr(da,"Stop");var fa=class extends co{constructor(t,i=t){super(lr("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+=Xn(t)+":"+i[t]+";";return s+="}",s}(t,i))}};Oe("Dom",{style(t,i){return this.put(new fa).rule(t,i)},fontface(t,i,s){return this.put(new fa).font(t,i,s)}}),dr(fa,"Style");var va=class extends Xh{constructor(t,i=t){super(lr("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")}};Oe({Container:{textPath:mr((function(t,i){return t instanceof Xh||(t=this.text(t)),t.path(i)}))},Text:{path:mr((function(t,i=!0){const s=new va;let e;if(t instanceof dh||(t=this.defs().path(t)),s.attr("href","#"+t,sr),i)for(;e=this.node.firstChild;)s.node.appendChild(e);return this.put(s)})),textPath(){return this.findOne("textPath")}},Path:{text:mr((function(t){return t instanceof Xh||(t=(new Xh).addTo(this.parent()).text(t)),t.path(this)})),targets(){return Vr(this.node,"href","textPath")}}}),va.prototype.MorphArray=nh,dr(va,"TextPath");var pa=class extends po{constructor(t,i=t){super(lr("use",t),i)}use(t,i){return this.attr("href",(i||"")+"#"+t,sr)}};function ga(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}Oe({Container:{use:mr((function(t,i){return this.put(new pa).use(t,i)}))}}),dr(pa,"Use"),gr([Eh,Ch,To,Lo,Go],Ne("viewbox")),gr([Fo,wh,yh,dh],Ne("marker")),gr(Xh,Ne("Text")),gr(dh,Ne("Path")),gr(vo,Ne("Defs")),gr([Xh,Jh],Ne("Tspan")),gr([xh,_o,Ro,Oh],Ne("radius")),gr(so,Ne("EventTarget")),gr(lo,Ne("Dom")),gr(co,Ne("Element")),gr(po,Ne("Shape")),gr([fo,ko],Ne("Container")),gr(Ro,Ne("Gradient")),gr(Oh,Ne("Runner")),Ir.extend([...new Set(ke)]),function(t=[]){uh.push(...[].concat(t))}([oo,Pr,Gr,zr,ro,Eo,nh,Wr]),gr(uh,{to(t){return(new oh).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 ma,ba={},ya=function(){if(ma)return ba;ma=1;var t={};return Object.defineProperty(ba,"__esModule",{value:!0}),ba.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},ba}(),wa=y(ya);const xa=["pl","fc","pp","ac"];function Sa(t){return t.replace(/\d+$/,"")}function $a(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 Ma{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 _a,ka;!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"}(_a||(_a={}));class Oa{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=t=>null===this.groupSeparator?h.format(t):h.formatToParts(t).map((t=>"group"===t.type?this.groupSeparator:t.value)).join(""),l=a(t/n);return(l===a(-0)?a(0):l).replace(/\s+(%)/g,"$1")}static translateScenarioLabel(t,i){if(null==t)return"";const s=new Xs(t);if(!s.isValid)return`${i.get(t)||t}`;let e,n;return _a.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 wa(t.map((t=>Oa.translateScenarioLabel(t,i))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:s.fontStyles.font,fontSize:s.fontStyles.size+"px"}).width}}Oa.formats=new Map,Oa.groupSeparator=null;class Na{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=Na.niceStep(i,t),e=Math.ceil(this.domainMin/s)*s;if(e+s===e||s<Math.pow(10,-15))return[this.domainMin];const n=Na.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:Na.stepDecimals(1===t.length?Math.abs(t[0]):(t[t.length-1]-t[0])/(t.length-1))}}function Aa(t,i,s,e=!1){return Oa.number(t,e?"percent":"decimal",i,i,1,s)}function Ra(t,i){return Na.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"}(ka||(ka={}));let Ta=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||ka.Top,this.horizontalHookLocation=h||ka.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");const a=this.isRelativeLabel&&this.isVarianceLabel&&!1===i.percentSign,l=i=>a?Oa.number(Number((100*i).toPrecision(15)),"decimal",e,o,1,this.styles.locale):Oa.number(i,t,e,o,h,this.styles.locale);n=l(Number(this.value));const c=l(0);this.isVarianceLabel&&Number(this.value)>0&&n!==c&&(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(as(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(as(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===ka.Left?(e="left",a=n.x()):this.horizontalHookLocation===ka.Center?(e="middle",a=n.x()-(o+2)/2):this.horizontalHookLocation===ka.Right&&(e="end",a=n.x()-o),this.verticalHookLocation===ka.Center?(u=n.y()-1.2*h/2,l=u+.2*h):this.verticalHookLocation===ka.Top?(u-=h/4,l=u+.2*h):this.verticalHookLocation===ka.Bottom&&(u-=h,l=u+.2*h),n.move(c,u),n.font({anchor:e}),null!=this.segmentFillColor?n.fill($a(this.segmentFillColor)):t.rect(o+2,.8*h).stroke(s).fill(s).opacity(.9).move(this.horizontalHookLocation===ka.Center?a:a-1,l).insertBefore(n),n}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}};const Ea={ac:1,pp:2,fc:3,pl:4};var Ca;!function(t){t[t.Above=0]="Above",t[t.Below=1]="Below",t[t.Left=2]="Left",t[t.Right=3]="Right"}(Ca||(Ca={}));class Pa{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=Ea[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 Ca.Above:a=t,l=i-r-o,c=ka.Bottom,u=ka.Center,d=t-s/2,f=i-r-o-e;break;case Ca.Below:a=t,l=i+r+o,c=ka.Top,u=ka.Center,d=t-s/2,f=i+r+o-e/4;break;case Ca.Left:a=t-r-o,l=i,c=ka.Center,u=ka.Right,d=t-r-o-s,f=i-.6*e;break;case Ca.Right:a=t+r+o,l=i,c=ka.Center,u=ka.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&&((Ea[s.scenarioType]||99)<i&&this.intersects(t,s))))}shouldHideScenarioLabel(t,i,s,e=20){const n=Ea[s]||99;return!(n<=1)&&this.scenarioLabels.some((s=>{if((Ea[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 Wa=["n","ne","e","se","s","sw","w","nw"],Da=Math.SQRT1_2;class za{constructor(t,i,s=new Pa){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 Wa){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*Da+.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:ka.Center}}}class Ua{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 Ua("local",t,i,s,0)}static grouped(t){return new Ua("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 Fa{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:si(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:si(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:si(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(ss,"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(Aa(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(Aa(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 Ga{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=wa(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 ja{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 Ia=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class Ba{adapt(t){const i=new ja;if(R.isOperator(t.operation)&&(i.operation=t.operation),R.isString(t.date)){const s=w.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 Ia){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 ja}}const Ya={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function Ha(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 Va(t,i){return void 0!==i&&(void 0!==i.min&&t<i.min||void 0!==i.max&&t>i.max)}function Xa(t,i){return"scenario"!==t.kind?null:i+D(t.slot)}function Ja(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?Xa(i.measures.x,S):null,M=null!==S?Xa(i.measures.y,S):null,_=null!==S&&void 0!==i.measures.size?Xa(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:"",k=`${u}\0${S}\0${t}`;if(d.has(k)){v++,f.length<5&&!f.includes(t)&&f.push(t);continue}const O=Ha(s,i.measures.x),N=Ha(s,i.measures.y);if(null===O.value||null===N.value){(O.varianceNoData||N.varianceNoData)&&p++;continue}if(Va(O.value,null===(r=i.domains)||void 0===r?void 0:r.x)||Va(N.value,null===(o=i.domains)||void 0===o?void 0:o.y)){g++;continue}const A={name:t,seriesKey:S,facetKey:u,x:O.value,y:N.value,row:s};if(void 0!==i.measures.size){const t=Ha(s,i.measures.size).value;if(null===t)continue;if(t<0){m++;continue}A.size=t}if(void 0!==i.measures.share){const t=Ha(s,i.measures.share).value;null!==t&&(t<0||t>1?(b++,A.share=Math.min(1,Math.max(0,t))):A.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?A.compare=null:Va(t,null===(h=i.domains)||void 0===h?void 0:h.x)||Va(e,null===(a=i.domains)||void 0===a?void 0:a.y)?(g++,A.compare=null):(A.compare={x:t,y:e},null!==n&&(A.compare.size=n))}if(d.add(k),x.has(u)||x.set(u,[]),x.get(u).push(A),null!==i.facetLevel){const t=s[Ya[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[Ya[i.seriesLevel]];null!=t&&t<(null!==(c=w.get(S))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&w.set(S,t)}}const k=[...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)})),O=k.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}})),N=new Set;for(const t of O)for(const i of t.points)N.add(i.seriesKey);const A=[...N].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 R=null,L=0;for(const t of O)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===R&&(R={xMin:t[0],xMax:t[0],yMin:s[0],yMax:s[0],sizeMax:0});for(const i of t)R.xMin=Math.min(R.xMin,i),R.xMax=Math.max(R.xMax,i);for(const t of s)R.yMin=Math.min(R.yMin,t),R.yMax=Math.max(R.yMax,t);for(const t of e)R.sizeMax=Math.max(R.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:O,series:A,extents:R,warnings:u,totalPoints:L}}class qa{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:z(e.x),y:z(e.y)});const c=new Ba;let u=[];try{""!==s&&(u=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=yi(t)}const d=(null!=u?u:[]).map((t=>c.adapt(t)));this.data=Ja(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=P(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=P(e.y.measure))&&void 0!==h?h:{kind:"scenario",slot:"ac2"},size:null!==(a=P(e.size.measure))&&void 0!==a?a:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(l=P(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 U(this.config.x.measure)}get yPercent(){return U(this.config.y.measure)}get sizePercent(){return U(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=wa(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=P(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}=x(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=P(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=S(i,e,"bubble");return{label:t,treatment:n,fill:this.treatmentFill(n,s,e)}}toString(){const t=new Eh;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 Ga(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 k,O=3*d,N={x:0,y:0,width:0,height:0},A=[];const R=Math.max(1,this.data.facets.length),L=null===(i=this.config.facet)||void 0===i?void 0:i.columns,T=Na.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}),E=Na.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-O-w);N={x:f.left+O,y:f.top+x+M,width:t,height:t/this.config.aspect},k=new Ma(R,L,N,this.styles.scaleFactors.panelGap*d);const i=k.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*d)))),e=new Na(E[0],E[1],i,0);A=e.ticks(s);const n=Ra(A,this.yPercent);O=Math.max(...A.map((t=>this.textWidth(Aa(t,n,this.styles.locale,this.yPercent)))),d)+this.styles.scaleFactors.axisTickLength*d+.4*d}this.canvasHeight=N.y+N.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,N.y-.6*d,"start");const C=this.buildPanels(k,T,E),P=C[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(C[0].rect.width/(7*d))))),W=Ra(P,this.xPercent),D=Ra(A,this.yPercent),z=this.config.sizeAreaPerUnit>0?Ua.grouped(this.config.sizeAreaPerUnit):Ua.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,A,W,D,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(p,C[i],t,z,P,A,W,D,k.isOuterLeft(i),k.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==$&&this.drawAxisTitleText(p,this.config.x,v,N.x+N.width,N.y+N.height+2.6*d,"end"),b&&("right"===this.config.legend.position?g.draw(p,m,N.x+N.width+d,N.y,"right"):g.draw(p,m,N.x,N.y+N.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 Na(i[0],i[1],r.x,r.x+r.width),h=new Na(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new Fa(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"),x=new za(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=S(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=S(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),x.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=ga(t,s.key,this.config);null===(p=this.drawBubble(w,h,a,l,o,n,r))||void 0===p||p.attr(as(c,"element")),x.registerMark(h,a,l),void 0!==t.share&&l>0&&(null===(g=this.drawShareSlice(w,h,a,l,t.share,$(r)))||void 0===g||g.attr(as(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,x,_,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=Aa(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:$a(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(as(ga(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),Na.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const Ka=["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"],Qa=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="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new qa(new se(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()),wi(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 Ka){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 fe(new pe,new ne,new ue(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};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{position:relative;display:inline-block}';const Za=["measure","label","unit"];function tl(t){const i=[],s=rl(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:nl(t,Za),invalidFields:i};const e={measure:s.trim()};return e.label=rl(t,"label",i),e.unit=rl(t,"unit",i),{config:e,unknownKeys:nl(t,Za),invalidFields:i}}const il=["show","decimals"];function sl(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:nl(t,il),invalidFields:s}}function el(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 nl(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function rl(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}const ol=["pl1","pp1","fc1"],hl=class{validateFilter(t){const i="ERR_filter";p(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=el(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=F(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";L(t)||G(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";T(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}=ks(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",sl(e,this.labelDefaults())):this.errors.remove(s)}validateScale(t){const i="WARN_scale";if(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-bullet-renderer");const{mode:t}=ii(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}=Xt(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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(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}=ks(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=P(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,tl(o))}validateEnum(t,i,s,e,n){L(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}=ks(this.actual,"measure");if(o)return null;const h=null!==r?tl(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=P(h.measure))||void 0===n?void 0:n.kind)?h:null}prepareTarget(){var t,i,s;const{data:e,parseError:n}=ks(this.target,"measure");if(n)return null;const r=null!==e?tl(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=ol.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=P(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 j.ROWGROUP;if("category"===s)return j.CATEGORY;if("subcategory"===s)return j.SUBCATEGORY;const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==e&&""!==e){const t=j[e.toUpperCase()];if(void 0!==t)return t}return j.CATEGORY}prepareOrder(){var t,i,s,e;const n="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let r;L(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=I[null===(s=this.orderDirection)||void 0===s?void 0:s.toUpperCase()])&&void 0!==e?e:I.ASC;if(L(r))return new B([Y.CATEGORYINDEX],o);const h=r.split(",").map((t=>Y[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new B(h.length>0?h:[Y.CATEGORYINDEX],o)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{show:t.show,decimals:t.decimals}:sl(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(g.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries(),...ie(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 rs(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=di(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 xs(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=el(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:Xt(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}]}}};hl.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 al{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 ll{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new al(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 al(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}class cl{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=yi(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===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY} as category`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP} as category`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY}`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP}`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.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=wa(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?"":Oa.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 Zs(this.ruleSet.getScenarioColorIndex(s))}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:Oa.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":Oa.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new Eh;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:si(n.axisLineWidth,this.em)}).attr(ss,"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:si(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(as(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=Na.niceStep(b,4),w=Math.ceil(b/y-1e-9*y)*y,x=new Na(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(as(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:si(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),_=Na.tickDecimals(M),k=p+n;for(const i of M){const s=x.scale(i);t.line(s,k,s,k+a.axisTickLength*h).stroke({color:this.styles.axisStyles.ac.stroke,width:si(a.axisLineWidth,this.em)}),this.drawText(t,Oa.number(i,"decimal",_,_,1,this.styles.locale),s,k+a.tickStripHeight*h-.2*h,{anchor:"middle"})}}))}drawValueText(t,i,s,e,n){""!==i&&this.drawText(t,i,s,e+.35*this.em,{}).attr(as(this.rowKey(n),"label"))}rowKey(t){return Object.assign(Object.assign({},us(this.config.level,t.category)),{scenario:this.config.actual.measure})}}class ul{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 dl{adapt(t){const i=new ul;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 ul}}class fl{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 vl{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 fl(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const pl=["bullet-target-missing","bullet-target-invalid","bullet-actual-negative","bullet-mixed-operation","bullet-target-none"],gl=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=j.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new cl(new se(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()),wi(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 pl){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 vl(new dl,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};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{position:relative;display:inline-block}';const ml={rowGroup:0,category:1,subCategory:2},bl=class{validateFilter(t){const i="ERR_filter";p(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=>Ds(t)))}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];L(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"];L(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=>Gs(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>Us(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>Is(t)))}validateAspect(t){const i="WARN_aspect";L(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";T(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(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-scatter-renderer");const{mode:t}=ii(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}=Xt(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(){Ss(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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}=ks(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:Ls(h),c=null!==(s=h.measure)&&void 0!==s?s:"";C(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}=ks(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}=ks(i,"measure");if(e||null===s)return null;const{config:n}=Ls(s);return null!==n&&C(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}=ks(this.iso,null);return i||null===t?null:Ds(t).config}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:Us(i,t).config}prepareLegend(){const{data:t,parseError:i}=ks(this.legend,null);return i||null===t?{show:!0,position:"right"}:Is(t).config}prepareFacet(){const{data:t,parseError:i}=ks(this.facet,null);return i||null===t?null:Gs(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=P(i);null!==t&&"scenario"===t.kind&&s.add(W(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&&ml[n]>=ml[e]&&(o=`series '${n}' vs point '${e}'`),null!==r){const t=null!=n?n:e;ml[r]>=ml[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(g.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 rs(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=di(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 xs(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=P(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=Xt(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}]}}};bl.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 yl{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=yl.ladderValues(s(.25),s(.75));if(e.length<2&&(e=yl.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 wl{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:z(e.x),y:z(e.y)});const a=new Ba;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=yi(t)}const c=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=Ja(c,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=P(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=P(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 U(this.config.x.measure)}get yPercent(){return U(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=wa(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=P(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=x(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),S(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 Eh;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 Ga(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,k=1.4*u+(""!==M?1.3*u:0);let O,N=3*u,A={x:0,y:0,width:0,height:0},R=[];const L=Math.max(1,this.data.facets.length),T=null===(s=this.config.facet)||void 0===s?void 0:s.columns,E=Na.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=Na.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-N-x);A={x:d.left+N,y:d.top+S+_,width:t,height:t/this.config.aspect},O=new Ma(L,T,A,this.styles.scaleFactors.panelGap*u);const i=O.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new Na(C[0],C[1],i,0);R=e.ticks(s);const n=Ra(R,this.yPercent);N=Math.max(...R.map((t=>this.textWidth(Aa(t,n,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=A.y+A.height+k+("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,A.y-.6*u,"start");const P=this.buildPanels(O,E,C),W=P[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(P[0].rect.width/(7*u))))),D=Ra(W,this.xPercent),z=Ra(R,this.yPercent);let U=!1;y&&(E[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,R,D,z,!0,!0,U):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,P[i],t,W,R,D,z,O.isOuterLeft(i),O.isOuterBottom(i),U,this.data.facets.length>1?t.key:"")})),""!==M&&this.drawAxisTitleText(v,this.config.x,f,A.x+A.width,A.y+A.height+2.6*u,"end"),m&&("right"===this.config.legend.position?p.draw(v,g,A.x+A.width+u,A.y,"right"):p.draw(v,g,A.x,A.y+A.height+k,"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 Na(i[0],i[1],r.x,r.x+r.width),h=new Na(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new Fa(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 za(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(as(ga(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(as(ga(c.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new yl(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:si(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:yl.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=>Na.stepDecimals(Math.abs(t)))));return t.map((t=>Aa(t,i,this.styles.locale)))}}const xl=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],Sl=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="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new wl(new se(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()),wi(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 xl){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 fe(new pe,new ne,new ue(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};Sl.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 $l=class{validateFilter(t){const i="ERR_filter";p(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(qt(t)||H(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)||J(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(qt(t))return void this.errors.remove(i);const s=F(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";qt(t)||L(t)||G(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";T(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";q(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){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const s=`WARN_${t}`;!T(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(s)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",L(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",L(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,s){const e=`WARN_${t}`;i?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+s+"' is not supported."})}prepareReferenceLine(){if(L(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(L(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",s=K(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.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",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: ${$l.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${ni(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: ${$l.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(this).t,this.resolveInherited=ri(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.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),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.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Bs(this.element,"bn-chart-structure-renderer");const{mode:t}=ii(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}=Xt(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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(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=Xt(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 _(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===ei(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=ii(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)`),_(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=Xt(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{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()));if(H(n.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return L(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 L(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&H(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=g,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(),...ie(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=ei(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: ${$l.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=ei(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: ${$l.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 L(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}`}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[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 L(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:I[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,titleBold:i["bn-chart-structure"].titleBold,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),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);const e="total"===t.thickness,n=e&&this.prepareVariances().length>0;return n?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||tt.ABSOLUTE,order:t.order||Z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:e&&!n?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),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 L(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){var e;const n=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),o=this.prepareStackConfig(),h=""===t,a=this.hidesScenarios()?qs([t]):this.prepareScenarios(),l=h&&(null==o?void 0:o.by)===Q.DIMENSIONS?a.slice(0,1):a;return i("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:l,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:n,pixelPerPercentage:r,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:o,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:h?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return rs(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=di(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=ws(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-structure-renderer"),f={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:li(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:ai(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=ei(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=ei(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}=ii(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(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const e=this.getFontStyles();return i(s,{key:"132c843c3a3b2a3780acf89370b6a6eb75c10170",style:e},i("div",{key:"84a2f28b516bfc71ca8145158cc48d9dcbcb46c4",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}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};$l.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 Ml=class{constructor(t,i,s,e,n,r,o,h,a=!1,l=null){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.rows=l,this.leftSideLabelLength=this.calculateSideLabelLength(r,o,h),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){if(this.rows&&t<this.rows.start.length){const i=this.rows.start[t]+this.rows.weight[t]/2;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}isNameBelowBar(){var t;return!!(null===(t=this.rows)||void 0===t?void 0:t.nameBelowBar)}getRowTopPositionY(t){const i=this.rows&&t<this.rows.start.length?this.rows.start[t]:t;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}getBarWidthAt(t){return this.spacings.barWidth*(this.rows&&t<this.rows.weight.length?this.rows.weight[t]:1)}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.getBarWidthAt(0)-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(){const t=this.rows?this.rows.total:this.numberOfColumns;return this.getAxisPositionY()+(t+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){var i;if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return(null===(i=this.rows)||void 0===i?void 0:i.nameBelowBar)?t: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}},_l=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}},kl=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}},Ol=class{constructor(t){this.container=new Eh,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 Nl,Al,Rl;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Nl||(Nl={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Al||(Al={})),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"}(Rl||(Rl={}));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,Rl[t])}}Ll.unitsGreat=["k","M","G","T","P","E","Z","Y"],Ll.unitsLeast=["m","my","n","p","f","a","z","y"];class Tl{adapt(t){return it.adaptDefaultString(t)}default(){return""}}class El{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 st(new Tl).default(),this.level=j.CATEGORY,this.filter="",this.measureScale=new La,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[]}}class Cl{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=it.adaptArray(t.data,this.dataRowAdapter),s=it.adaptArray(t.scenarios,this.stringAdapter),e=new El(i,s);return R.isArray(t.variances)&&(e.variances=it.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),R.isString(t.sums)&&["groups","total","all"].includes(t.sums)&&(e.sums=t.sums),R.isString(t.sumTitle)&&(e.sumTitle=t.sumTitle),R.isString(t.valueSuffix)&&(e.valueSuffix=t.valueSuffix),R.isBoolean(t.scenarioLabelTop)&&(e.scenarioLabelTop=t.scenarioLabelTop),R.isBoolean(t.hideScenarioName)&&(e.hideScenarioName=t.hideScenarioName),R.isExisting(t.referenceLine)&&(e.referenceLine=t.referenceLine),R.isArray(t.italicCategories)&&(e.italicCategories=it.adaptArray(t.italicCategories,this.stringAdapter)),e}default(){return new El([],[])}}let Pl=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?Js(e,null,!0):e;this.variance="neg"===n||n===jl.NEG?jl.NEG:"pos"===n||n===jl.POS?jl.POS:jl.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:jl.NEU===this.variance?jl.NEU:jl.POS===this.variance?jl.NEG:jl.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 Wl{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 Dl{constructor(){}adapt(t){const i=new Wl;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 Wl}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 zl{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.titleBold=!1,this.valueSuffix="",this.locale="de"}}class Ul{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 zl(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.titleBold=!0===t.titleBold,i.pattern=new kl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new zl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class Fl{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 Gl{adapt(t){const i=new Fl;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 Fl}}var jl,Il,Bl;!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"}(jl||(jl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Il||(Il={})),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"}(Bl||(Bl={}));class Yl{constructor(t,i,s,e,n,r,o,h){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.bold=!1,this.italic=!1,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||Bl.Top,this.horizontalHookLocation=h||Bl.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setEmphasis(t,i){return this.bold=t,this.italic=i,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,e,n,r;if(this.isEmpty())return this;const o=this.group;let h;const a=this.styles.fontStyles.background||"#ffffff";let l="";if(!1===Number.isNaN(Number(this.value))){let e=t.percent,n=t.percent,r=1,o="percent";!1===this.isRelativeLabel&&(e=t.decimal,n=t.decimal,r=i.value,o="decimal"),h=Oa.number(Number(this.value),o,e,n,r,this.styles.locale);const a=Oa.number(0,o,e,n,r,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&h!==a&&(l="+"),"number"!=typeof this.value||this.isVarianceLabel||this.isRelativeLabel||(h+=null!==(s=this.styles.valueSuffix)&&void 0!==s?s:"")}else h=""+this.value;const c=o.text(l+h);(null===(e=this.styles.fontStyles)||void 0===e?void 0:e.size)&&c.attr("font-size",this.styles.fontStyles.size),(null===(n=this.styles.fontStyles)||void 0===n?void 0:n.family)&&c.attr("font-family",this.styles.fontStyles.family),this.bold&&c.font({weight:"bold"}),this.italic&&c.font({style:"italic"}),c.move(this.x,this.y);const u=c.bbox(),d=u.w,f=u.h;if(null!=this.maxWidth&&d>this.maxWidth)return null===(r=this.group)||void 0===r||r.remove(),this.group=null,this;let v="start";return this.horizontalHookLocation===Bl.Right?(v="end",c.move(c.x()-c.length(),c.y())):this.horizontalHookLocation===Bl.Center&&(v="middle",c.move(c.x()-c.length()/2,c.y())),this.verticalHookLocation===Bl.Center?c.move(c.x(),c.y()-f/2):this.verticalHookLocation===Bl.Bottom&&c.move(c.x(),c.y()-f),c.font({anchor:v}),null!=this.segmentFillColor?c.fill($a(this.segmentFillColor)):null==o||o.rect(d,.9*f).stroke(a).fill(a).opacity(.7).move(c.x(),c.y()+.1*f).insertBefore(c),this.pointKey&&(null==o||o.attr(as(this.pointKey,this.pointPart))),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Hl=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 Yl(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Bl.Bottom,Bl.Center).setEmphasis(this.style.titleBold,!1),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 Vl{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=Bl.Left;s.value<0&&(i=Bl.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Yl(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Bl.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}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),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,n;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let r=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(r=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const o=this.convertToSVGStyle(r,"stroke");let h=this.convertToSVGStyle(r,"fill");const a=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=a){const t=this.styles.pattern.get(a);null!=t&&(h=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(as(this.dataPoint.key)),null===(e=this.barGroup)||void 0===e||e.attr(as(this.dataPoint.key,"element")),this.isVarianceBar||null===(n=this.barGroup)||void 0===n||n.attr("data-bn-value",this.dataPoint.value),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(h,o):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(h).stroke(o).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(){if(null!=this.scenarioLabel&&!this.scenarioLabel.isEmpty()&&!this.isVarianceBar){let t=this.dimensions.scenarioLabelXPos;if(this.nameBesideAxis()){const i=this.dataPoint.getScaledUnit()<0?-1:1;t=this.position.getBarPositionX()+i*this.position.spacings.labelToAxis}this.scenarioLabel.setPos(t,this.dimensions.scenarioLabelYPos).draw()}}nameBesideAxis(){return this.isPrimaryBar&&this.position.isNameBelowBar()}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){if(this.isPrimaryBar){let i=Bl.Center;return this.nameBesideAxis()&&(i=this.dataPoint.getScaledUnit()<0?Bl.Right:Bl.Left),new Yl(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Bl.Top,i)}return new Yl(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Bl.Bottom,Bl.Center)}}let Xl=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 Yl(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Bl.Bottom:Bl.Top,Bl.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(as(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(as(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)}},Jl=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=Bl.Left;s.value<0&&(i=Bl.Right),this.label=new Yl(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,r?et:s.value,this.styles,Bl.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),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}){var i,s,e;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(as(this.dataPoint.key)),this.barGroup.attr(as(this.dataPoint.key,"element"));const n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),r=n.stroke;let o=n.fill;const h=this.barStyles[this.dataPoint.getScenario()];if(null!=h&&h.fillpattern){const t=this.styles.pattern.get(h.fillpattern);null!=t&&null!=t.pattern&&(o=t.pattern)}this.drawNeedleHead(o,r),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(e=this.label)||void 0===e||e.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,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 ql{constructor(t,i,s,e,n,r,o,h,a,l,c,u={}){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.options=u,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){var s;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const e=this.dataPoint.value,n=this.dataPoint.pixelPerUnit,r=this.position.getBarPositionX(),o=this.position.getBarWidthAt(this.index),h=Math.abs(this.segment.end-this.segment.start)*n,a=r+Math.min(this.segment.start,this.segment.end)*n,l=this.position.getBarPositionY(this.index,!0),c=this.styles.stackColors,u=c[this.segmentIndex%c.length],d={color:u},f={color:u,width:.5};this.barGroup.attr(as(this.dataPoint.key,"element")),this.barGroup.attr("data-bn-value",e),this.barGroup.rect(Math.max(h,.5),o).fill(d).stroke(f).cy(l).x(a);const v=h-Math.min(6,.375*this.styles.fontStyles.size),{bold:p=!1,italic:g=!1}=this.options,m=this.stackMode===tt.RELATIVE&&null!==(s=this.options.label)&&void 0!==s?s:"share";if(v>0){const s=a+h/2;if(this.stackMode!==tt.RELATIVE&&this.stackMode!==tt.ABSOLUTE_RELATIVE||"value"===m)new Yl(this.group,s,l,"STACK_SEG",e,this.styles,Bl.Center,Bl.Center).setSegmentFill(u).setEmphasis(p,g).setMaxWidth(v).setPoint(this.dataPoint.key).draw(t,i);else{const i="plain-share"===m?Oa.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):Oa.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new Yl(this.group,s,l,"STACK_SEG",i,this.styles,Bl.Center,Bl.Center).setSegmentFill(u).setEmphasis(p,g).setMaxWidth(v).setPoint(this.dataPoint.key).draw()}}}drawTotalLabel(t={percent:2,decimal:1},i=new La,s){var e,n;if(this.stackMode===tt.RELATIVE&&!this.options.total)return;const r=this.stack.total<0,o=this.position.getLabelPositionX((r?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),h=this.position.getBarPositionY(this.index,!0);new Yl(this.group,o,h,"STACK_TOTAL",this.stack.total,this.styles,Bl.Center,r?Bl.Right:Bl.Left).setEmphasis(null!==(e=this.options.bold)&&void 0!==e&&e,null!==(n=this.options.italic)&&void 0!==n&&n).setPoint(s,"total").draw(t,i)}}let Kl=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 Vl(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 Vl(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 Jl(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 Vl(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 Xl(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 Xl(this.position,n,r,t.scenario,this.styles,t,i,o,!1)}isFirstDataPoint(t){return 0===t}};const Ql=.001;function Zl(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 tc(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 ic(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Ql,(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 sc(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 ec(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 nc(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 rc{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new Pl(0,jl.AC1,1,jl.NEU),this.highestDataPointValue=new Pl(0,jl.AC1,1,jl.NEU),this.smallestVarianceDataPointValue=new Pl(0,jl.AC1,1,jl.NEU),this.highestVarianceDataPointValue=new Pl(0,jl.AC1,1,jl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=j.CATEGORY,this.hideCategories=!1,this.axisScenario=jl.AC1,this.CSS_CATEGORIES="categories",this.state=Nl.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=ec([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.db=i,this.tableName=s,this.ruleSet=t||new se,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 Ml(new _l(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||this.scenarioLabelTop,this.rowLayout())}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new se}setConfig(t){var i,s;this.state=Nl.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.sums=t.sums,this.sumTitle=t.sumTitle,this.styles.valueSuffix=t.valueSuffix,this.scenarioLabelTop=t.scenarioLabelTop,this.hideScenarioName=t.hideScenarioName,this.referenceLine=t.referenceLine,this.italicCategories=t.italicCategories,this.dataModel=this.populateModel(e,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==Q.SCENARIOS&&this.populateDimensionStackSegments(e,t.stackConfig,t.level),this.addSumRows(e);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({},us(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));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();const n=this.dataModel.filter((t=>!t.sum));this.smallestDataPointValue=this.findSmallestDataPointValue(n),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(n),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||Oa.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=Nl.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=Nl.DIRTY,this.queryError=void 0,this.fromExpr=M(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=yi(t))}getUnitBarExtent(){var t,i,s,e;const n=this.isStacked(),r=this.getVarianceType(),o=r!==Al.NONE,h=o?this.highestVarianceDataPointValue:this.highestDataPointValue,a=o?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Zl({fixedDomain:n?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:r===Al.RELATIVE,maxPositive:Math.max(null!==(t=null==h?void 0:h.value)&&void 0!==t?t:0,n||o?0:null!==(s=null===(i=this.referenceLine)||void 0===i?void 0:i.value)&&void 0!==s?s:0),minNegative:null!==(e=null==a?void 0:a.value)&&void 0!==e?e:0})}getPercentBarExtent(){var t,i,s,e;return tc({relativeVariance:this.getVarianceType()===Al.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.hasPercentMark()?.8*this.position.fontSize:0)+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new Eh)}toString(){const t=new Eh;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===Nl.DIRTY&&(this.state=Nl.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.drawPercentMark(t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)),0===this.variancesDataModel.length&&this.drawReferenceLine(t)}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=wa(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:this.styles.titleBold?"bold":"normal"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Oa.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=te(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=jl.AC1;if(null!=t&&t.length>0){const s=new Xs(t.toString());s.isValid&&(i=Zs(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=jl.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 Xs(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 Pl(n(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,jl.NEU),scenario2:new Pl(n(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,jl.NEU),scenario3:new Pl(n(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,jl.NEU),scenario4:new Pl(n(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,jl.NEU)}}),{id:9999,category:"REST",type:Al.NONE,scenario1:new Pl(NaN,i[0],this.pixelPerUnit,jl.NEU),scenario2:new Pl(NaN,i[1],this.pixelPerUnit,jl.NEU),scenario3:new Pl(NaN,i[2],this.pixelPerUnit,jl.NEU),scenario4:new Pl(NaN,i[3],this.pixelPerUnit,jl.NEU)});s.push(r)}createDataRows(t,i,s){t.forEach(((t,e)=>{i.push({id:e,category:t.category,type:Al.NONE,scenario1:new Pl(t[s[0]],s[0],this.pixelPerUnit,jl.NEU),scenario2:new Pl(t[s[1]],s[1],this.pixelPerUnit,jl.NEU),scenario3:new Pl(t[s[2]],s[2],this.pixelPerUnit,jl.NEU),scenario4:new Pl(t[s[3]],s[3],this.pixelPerUnit,jl.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===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY} as category`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP} as category`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY}`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP}`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=wa(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 Pl(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 Pl(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===tt.RELATIVE?1:0,n=(t,i)=>({prefix:t,segments:i,layout:sc(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=Sa(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of xa)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=ec(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return nc(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===tt.RELATIVE&&"value"!==this.stackConfig.labels?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.isTextSum(t)?[]:this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return wa(Oa.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix,{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 Xs(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 Pl(this.calculateVariance(r,i[e],o),r.base,a,h);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},us(this.level,i[e].category)),{scenario:t[n]})),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Al.RELATIVE:Al.ABSOLUTE,scenario1:l,scenario2:new Pl(null,null,null,null),scenario3:new Pl(null,null,null,null),scenario4:new Pl(null,null,null,null),sum:i[e].sum})}}}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===Al.RELATIVE?nt(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,i=!1){const s=i?"":this.styles.valueSuffix;return wa(Oa.number(t,"decimal",1,0,1,this.styles.locale)+s,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,e=t=>Oa.number(t,"percent",s,s,1,this.styles.locale);return t>0&&e(t)!==e(0)&&(i+=wa("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=wa(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,wa(Oa.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)=>{var r;t.type===Al.RELATIVE&&(n=!0);let o=Bl.Right,h=!0,a=0;if(s){const i=this.stackLabelPlace(t);h=!i.flipped,a=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&!this.hasSumNumbers(this.dataModel[i])&&(h=!1);h||(o=Bl.Left),new Yl(e,this.position.getCategoryPositionX(h)+a,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Bl.Center,o).setEmphasis(!!(null===(r=this.dataModel[i])||void 0===r?void 0:r.sum),this.isItalic(t.category)).draw()})),t.forEach(((t,i)=>{const s=this.dataModel[i];if(!(null==s?void 0:s.sum))return;const n=this.position.getBarCenterPositionY(i)-this.position.spacings.categoryWidth/2,r=this.hideCategories?this.position.getAxisPositionX():this.styles.padding.left;e.line(r,n,this.position.getAxisPositionX()+this.sumRowExtent(s),n).stroke({color:"#000000",width:Math.max(.5,this.position.spacings.axisLineWidth/2)}).addClass("sum-line")})),new Hl({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios");let e=-1;t.forEach(((t,i)=>{t.sum||(e=i)}));const n=new Kl(this.position,s,this.scenarioStyles(),this.scenarioLabelTop?0:e+1,this.i18n);n.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.sum?this.drawSumValue(t,i,s):(n.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),n.createSecondaryBar(t.scenario2,i).draw(),n.createPrimaryMarker(t.scenario3,i).draw(),n.createSecondaryMarker(t.scenario4,i).draw())}));const r=t.find((t=>!t.sum));if(this.scenarioLabelTop&&r&&!r.scenario1.isEmpty()&&null!=r.scenario1.scenario){const t=r.scenario1.scenario;new Yl(s,this.position.getBarPositionX()+this.position.spacings.labelToAxis,this.position.getStackedHeaderPositionY(),"SCENARIO_HEADER",this.i18n.get(t)||t,this.styles,Bl.Bottom,Bl.Left).draw()}}sumPoints(t){const i=[t.scenario1,t.scenario2,t.scenario3,t.scenario4].filter((t=>null!=t&&!t.isEmpty()&&Number.isFinite(t.value))),s=this.scenarioPropOrder,e=t=>{const i=s.indexOf(t.scenario);return-1===i?s.length:i};return i.sort(((t,i)=>e(t)-e(i)))}hasSumNumbers(t){return!!(null==t?void 0:t.sum)&&0===this.variancesDataModel.length&&!this.stackConfig&&this.sumPoints(t).length>1}sumValuesWidth(t){const i=this.styles.fontStyles.size,s=i*this.styles.scaleFactors.labelToBar,e=this.sumPoints(t);if(0===e.length)return 0;const n=e.map((t=>this.boldWidth(this.sumText(t.value))));return 1===e.length?s+n[0]:s+n.reduce(((t,s)=>t+.9*i+s),0)+(e.length-1)*i*1.4}drawSumValue(t,i,s){const e=this.sumPoints(t);if(0===e.length)return;const n=this.styles.fontStyles.size,r=this.position.getBarCenterPositionY(i),o=s.group().id(`sum_${i}`),h=(t,i,s)=>{new Yl(o,i,r,`SUM_${t.scenario}`,t.value,this.styles,Bl.Center,s).setEmphasis(!0,!1).setPoint(t.key).draw(this.dataFormatDigits,this.measureScale)};if(1===e.length){const t=e[0].value<0;return void h(e[0],this.position.getLabelPositionX(t?-1e-6:0),t?Bl.Right:Bl.Left)}const a=.6*n,l=this.scenarioStyles().barStyles;let c=this.position.getLabelPositionX(0);for(const t of e){const i=l.getSVGStyle(t.getScenario());o.rect(a,a).fill({color:(null==i?void 0:i.fill)||"#000000"}).stroke({color:(null==i?void 0:i.stroke)||"#000000",width:1}).cy(r).x(c),h(t,c+a+.3*n,Bl.Left),c+=.9*n+this.boldWidth(this.sumText(t.value))+1.4*n}}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Kl(this.position,s,this.scenarioStyles(),t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{if(t.type===Al.RELATIVE){const s=e.createRelativeVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits)}else{const s=e.createVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.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,n=this.stackConfig.mode===tt.RELATIVE&&"value"===this.stackConfig.labels,r=n?"value":this.stackConfig.percentMark?"plain-share":"share";t.forEach(((t,i)=>{const o=this.stackGroups(t);if(this.isTextSum(t))return void this.drawSumText(t,i,s);const h={label:r,total:n,bold:!!t.sum,italic:this.isItalic(t.category)};o.forEach(((n,r)=>{let a=null;n.segments.forEach(((t,l)=>{const c=new ql(this.position,this.styles,t.dataPoint,i,n.layout.segments[l],t.scenario,o.length>1?o.length-1-r:l,this.stackConfig.mode,n.layout,e,s,h);c.draw(this.dataFormatDigits,this.measureScale),a=c})),a&&n.hasValue&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},us(this.level,t.category)),{scenario:o.length>1?n.prefix:void 0}))}))}))}drawStackedHeaders(t,i){var s;if(!this.stackConfig||0===t.length)return;const e=null!==(s=t.find((t=>!this.isTextSum(t))))&&void 0!==s?s:t[0];if(this.stackConfig.by!==Q.SCENARIOS&&(!e.stackSegments||0===e.stackSegments.length))return;const n=this.stackGroups(e);if(0===n.length)return;const r=i.group().id("StackedHeaders"),o=this.position.getBarPositionX(),h=this.position.getStackedHeaderPositionY(),a=(t,i)=>{new Yl(r,t,h,"STACK_HEADER",i,this.styles,Bl.Bottom,Bl.Center).draw()};if(n.length>1)return void n.forEach((t=>{a(o+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[l]=n;this.stackConfig.totalTitle&&(this.stackConfig.mode!==tt.RELATIVE||"value"===this.stackConfig.labels)&&new Yl(r,this.position.getLabelPositionX(l.layout.positive*this.pixelPerUnit),h,"STACK_TOTAL_HEADER",this.stackConfig.totalTitle,this.styles,Bl.Bottom,Bl.Left).draw(),l.segments.forEach(((t,i)=>{const{start:s,end:e}=l.layout.segments[i];a(o+(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}stackHeaderExtent(){var t;if(!this.stackConfig||0===this.dataModel.length)return 0;const i=null!==(t=this.dataModel.find((t=>!this.isTextSum(t))))&&void 0!==t?t:this.dataModel[0],s=this.stackGroups(i);if(1!==s.length)return 0;const[e]=s;let n=0;return e.segments.forEach(((t,i)=>{const{start:s,end:r}=e.layout.segments[i],o=String(this.i18n.get(t.scenario)||t.scenario),h=wa(o,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;n=Math.max(n,(s+r)/2*t.dataPoint.pixelPerUnit+h/2)})),n}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Al.NONE}calculateLeftSideWidth(t){var i,s,e,n,r;let o=0;const h=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Al.NONE===t&&this.isStacked()){if(this.stackSides.negative>0){o=this.stackSides.negative*this.pixelPerUnit;const t=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);this.stackSides.minTotal<0&&t&&(o+=h+this.calculateTotalLabelWidth(this.stackSides.minTotal))}this.stackLabelClearance.left>0&&(o=Math.max(o,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()))}else if(Al.NONE===t&&null!=(null===(e=this.smallestDataPointValue)||void 0===e?void 0:e.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);o=Math.abs(this.smallestDataPointValue.getScaledUnit())+h+t}else if(Al.RELATIVE===t&&null!=(null===(n=this.smallestVarianceDataPointValue)||void 0===n?void 0:n.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);o=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+h+t}else if(Al.ABSOLUTE===t&&null!=(null===(r=this.smallestVarianceDataPointValue)||void 0===r?void 0:r.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value,!0);o=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+h+t}return o<=this.titleLength?this.titleLength:o}calculateRightSideWidth(t){var i,s,e,n,r,o,h,a;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,o=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);let h=t+this.calculateTextBoxWidth(this.stackSides.maxTotal);o||(h=this.hasPercentMark()?this.boldWidth("100%")/2:0);let a=Math.max(this.stackSides.positive*this.pixelPerUnit+h,this.stackHeaderExtent());if(this.stackSides.minTotal<0&&(a=Math.max(a,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),(null===(e=this.stackConfig)||void 0===e?void 0:e.totalTitle)&&o){const i=wa(this.stackConfig.totalTitle,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;a=Math.max(a,this.stackSides.positive*this.pixelPerUnit+t+i)}return Math.max(a,this.titleLength,null!==(r=null===(n=this.sumColumns())||void 0===n?void 0:n.width)&&void 0!==r?r:0,this.referenceLineExtent())}let l=0;const c=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Al.NONE===t&&null!=(null===(o=this.highestDataPointValue)||void 0===o?void 0:o.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);l=Math.abs(this.highestDataPointValue.getScaledUnit())+c+t}else if(Al.RELATIVE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);l=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+c+t}else if(Al.ABSOLUTE===t&&null!=(null===(a=this.highestVarianceDataPointValue)||void 0===a?void 0:a.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value,!0);l=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+c+t}l=Math.max(l,this.referenceLineExtent());for(const i of this.dataModel)i.sum&&Al.NONE===t&&(l=Math.max(l,this.sumRowExtent(i)));return l<=this.titleLength?this.titleLength:l}populateDimensionStackSegments(t,i,s){var e;if(0===this.rowCount||!this.fromExpr||0===t.length)return;const n={[j.ROWGROUP]:"category",[j.ROWGROUPINDEX]:"category",[j.CATEGORY]:"subCategory",[j.CATEGORYINDEX]:"subCategory"}[s];if(!n)return;const r=s.toString(),o=t[0];let h;try{h=this.db.exec(`SELECT [${r}] as displayGroup, [${n}] as stackLabel, MIN([${n}Index]) as stackIndex, SUM([${o}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${r}], [${n}]`)}catch(t){return void this.failQuery(t)}const a=new Map;for(const t of h){if(null==t.stackValue||null==t.stackLabel)continue;const i=t.stackLabel,s=Number.isFinite(Number(t.stackIndex))&&null!=t.stackIndex?Number(t.stackIndex):NaN,e=a.get(i);(void 0===e||Number.isNaN(e)&&!Number.isNaN(s)||s<e)&&a.set(i,s)}const l=[...a.keys()];[...a.values()].every((t=>!Number.isNaN(t)))&&l.sort(((t,i)=>a.get(t)-a.get(i)));const c=new Map;for(const t of h){const i=t.displayGroup;c.has(i)||c.set(i,new Map),null!=t.stackValue&&null!=t.stackLabel&&c.get(i).set(t.stackLabel,t.stackValue)}const u=new Set(this.dataModel.map((t=>t.category))),d=new Map;for(const[t,i]of c)if(!u.has(t))for(const[t,s]of i)d.set(t,(null!==(e=d.get(t))&&void 0!==e?e:0)+s);for(const t of this.dataModel){const i=9999!==t.id||c.has(t.category)?c.get(t.category):d,s=i&&i.size>0?l.map((t=>{var s;return{label:t,value:null!==(s=i.get(t))&&void 0!==s?s:NaN}})):void 0;t.stackSegments=s&&s.length>0?s.map((i=>{const s=new Pl(i.value,o,this.pixelPerUnit,jl.NEU);return s.key=Object.assign(Object.assign({},us(this.level,t.category)),{[n]:i.label,scenario:o}),{label:i.label,value:i.value,dataPoint:s}})):[]}}isTextSum(t){return!!t.sum&&!!this.stackConfig&&this.stackConfig.mode!==tt.RELATIVE}isItalic(t){return this.italicCategories.includes(t)}hasPercentMark(){var t;return!!(null===(t=this.stackConfig)||void 0===t?void 0:t.percentMark)&&this.stackConfig.mode===tt.RELATIVE&&0===this.variancesDataModel.length&&this.isStacked()}addSumRows(t){if("none"===this.sums||0===this.dataModel.length)return;const i=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,s=(s,e,n)=>{var r,o;const h=(e,n)=>new Pl(void 0===t[n]?void 0:s.reduce(((t,s)=>i(t,s[e].value)),NaN),t[n],this.pixelPerUnit,jl.NEU),a={id:1e4+this.dataModel.length,category:e,type:Al.NONE,scenario1:h("scenario1",0),scenario2:h("scenario2",1),scenario3:h("scenario3",2),scenario4:h("scenario4",3),sum:n};if(s.some((t=>t.stackSegments))){const e=new Map;for(const t of s)for(const s of null!==(r=t.stackSegments)&&void 0!==r?r:[])e.set(s.label,i(null!==(o=e.get(s.label))&&void 0!==o?o:NaN,s.value));a.stackSegments=[...e].map((([i,s])=>({label:i,value:s,dataPoint:new Pl(s,t[0],this.pixelPerUnit,jl.NEU)})))}return a},e=this.dataModel,n=[],r="total"===this.sums?new Map:this.rowGroups();if(r.size>0){const t=[...new Set([...r.values()].sort(((t,i)=>t.index-i.index)).map((t=>t.name)))];for(const i of t){const t=e.filter((t=>{var s;return(null===(s=r.get(t.category))||void 0===s?void 0:s.name)===i}));if(0===t.length)continue;const o=s(t,i,"group");o.gapAfter=!0,n.push(...t,o)}n.push(...e.filter((t=>!r.has(t.category))))}else n.push(...e);"total"!==this.sums&&"all"!==this.sums||n.push(s(e,this.sumTitle||"SUM_TOTAL","total")),this.dataModel=n}rowGroups(){const t=new Map;if(this.level!==j.CATEGORY&&this.level!==j.CATEGORYINDEX)return t;let i;try{i=this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`)}catch(i){return this.failQuery(i),t}const s=new Map;return i.forEach(((i,e)=>{var n;if(null==i.rowGroup||""===i.rowGroup)return;const r=String(i.rowGroup),o=Number(i.rowGroupIndex),h=null!=i.rowGroupIndex&&Number.isFinite(o)?o:null!==(n=s.get(r))&&void 0!==n?n:e;s.has(r)||s.set(r,h),t.set(String(i.category),{name:r,index:Math.min(h,s.get(r))})})),t}rowLayout(){var t;const i=this.dataModel,s="total"===(null===(t=this.stackConfig)||void 0===t?void 0:t.thickness),e=i.reduce(((t,i,s)=>i.sum?t:s),-1),n=!this.stackConfig&&!this.scenarioLabelTop&&!this.hideScenarioName&&e>=0&&e<i.length-1;if(!s&&!n&&!i.some((t=>t.gapAfter)))return null;const r=i.map((t=>{if(!s||t.sum)return null;const i=this.stackGroups(t),e=i[i.length-1];return e?Math.abs(e.layout.total):0})),o=this.rowWeights(r),h=[],a=[];let l=0;return i.forEach(((t,s)=>{const r=o[s];h.push(l),a.push(r),l+=r+(t.gapAfter&&s<i.length-1?.5:0)+(n&&s===e?1:0)})),{start:h,weight:a,total:l,nameBelowBar:n}}rowWeights(t){const i=Math.min(1,1/this.styles.scaleFactors.categoryWidth),s=t.map((t=>null===t?1:0)),e=new Set(t.flatMap(((t,i)=>null===t?[]:[i])));let n=e.size;for(;;){const r=[...e].reduce(((i,s)=>i+t[s]),0);if(r<=0){e.forEach((t=>s[t]=n/e.size));break}const o=[...e].filter((s=>t[s]/r*n<i));if(0===o.length||o.length===e.size){e.forEach((i=>s[i]=t[i]/r*n));break}for(const t of o)s[t]=i,n-=i,e.delete(t)}return s}boldWidth(t){return wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:"bold"}).width}sumText(t){const i=this.dataFormatDigits.decimal;return Oa.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix}sumColumns(){const t=this.dataModel.filter((t=>this.isTextSum(t)));if(0===t.length)return null;const i=this.styles.fontStyles.size,s=.6*i,e=.3*i,n=1.4*i,r=[];let o=0;for(const i of t){const t=this.stackGroups(i),s=t[t.length-1];s&&(s.segments.forEach(((t,i)=>{var s;const e=Number.isFinite(t.value)?this.boldWidth(this.sumText(t.value)):0;r[i]=Math.max(null!==(s=r[i])&&void 0!==s?s:0,e)})),o=Math.max(o,this.boldWidth(this.sumText(s.layout.total))))}const h=[];let a=.3*i;for(const t of r.length>1?r:[])h.push(a),a+=s+e+t+n;return{x:h,totalX:a,width:a+o,key:s,keyGap:e}}drawSumText(t,i,s){const e=this.sumColumns(),n=this.stackGroups(t),r=n[n.length-1];if(!e||!r)return;const o=this.position.getBarPositionX(),h=this.position.getBarCenterPositionY(i),a=this.styles.stackColors,l=s.group().id(`stacked_sum_${i}`);r.segments.forEach(((t,i)=>{if(!Number.isFinite(t.value)||void 0===e.x[i])return;const s=o+e.x[i];l.rect(e.key,e.key).fill({color:a[i%a.length]}).cy(h).x(s),new Yl(l,s+e.key+e.keyGap,h,`SUM_SEG_${i}`,t.value,this.styles,Bl.Center,Bl.Left).setEmphasis(!0,!1).setPoint(t.dataPoint.key).draw(this.dataFormatDigits,this.measureScale)})),new Yl(l,o+e.totalX,h,"SUM_TOTAL",r.layout.total,this.styles,Bl.Center,Bl.Left).setEmphasis(!0,!1).setPoint(us(this.level,t.category),"total").draw(this.dataFormatDigits,this.measureScale)}sumRowExtent(t){var i,s,e;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(this.variancesDataModel.length>0)return 0;if(this.isTextSum(t))return null!==(s=null===(i=this.sumColumns())||void 0===i?void 0:i.width)&&void 0!==s?s:0;if(this.stackConfig){const i="value"===this.stackConfig.labels?n+this.boldWidth(this.sumText(null!==(e=t.scenario1.value)&&void 0!==e?e:0)):0;return this.stackSides.positive*this.pixelPerUnit+i}return this.sumValuesWidth(t)}referenceLineOffset(){var t;const i=this.referenceLine;return!i||!Number.isFinite(i.value)||this.variancesDataModel.length>0?null:((null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===tt.RELATIVE?i.value/100:i.value)*this.pixelPerUnit}referenceLineExtent(){var t;const i=this.referenceLineOffset();if(null===i||i<=0)return 0;const s=(null===(t=this.referenceLine)||void 0===t?void 0:t.label)?wa(this.referenceLine.label,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width:0;return i+Math.max(s/2,.25*this.styles.fontStyles.size)}drawPercentMark(t){if(!this.hasPercentMark())return;const i=t.group().id("PercentMark"),s=this.styles.fontStyles.size,e=this.position.getBarPositionX()+this.stackSides.positive*this.pixelPerUnit,n=this.position.getAxisPositionY(),r=this.position.getAxisEndPositionY(),o=r+.15*s,h=o+.75*s;i.line(e,n,e,r).stroke({color:"#000000",width:this.position.spacings.axisLineWidth}),i.polygon(`${e},${o} ${e-.28*s},${h} ${e+.28*s},${h}`).fill("#000000"),new Yl(i,e,h+.1*s,"PERCENT_MARK","100%",this.styles,Bl.Top,Bl.Center).setEmphasis(!0,!1).draw()}drawReferenceLine(t){const i=this.referenceLine,s=this.referenceLineOffset();if(!i||null===s||0===this.dataModel.length)return;const e=t.group().id("ReferenceLine"),n=this.styles.fontStyles.size,r=`var(--bn-annotation-color, ${a["bn-annotation"].color})`,o=this.position.getBarPositionX()+s,h=this.position.getStackedHeaderPositionY()-(this.stackConfig||this.scenarioLabelTop?1.1*n:0),l=t=>{var s,e;if(t.sum)return!1;if(!this.stackConfig)return(null!==(s=t.scenario1.value)&&void 0!==s?s:0)>=i.value;const n=null===(e=this.stackGroups(t)[0])||void 0===e?void 0:e.layout.segments[0];return null!=n&&n.end*this.pixelPerUnit>=o-this.position.getBarPositionX()};let c=this.dataModel.findIndex((t=>!l(t)))-1;c<0&&(c=this.dataModel.reduce(((t,i,s)=>i.sum?t:s),0));const u=this.position.getBarCenterPositionY(c)+this.position.getBarWidthAt(c)/2;e.line(o,h,o,u).attr("style",`stroke: ${r}; stroke-width: ${Math.max(1,this.position.spacings.axisLineWidth)}px`),e.polygon(`${o},${h+.5*n} ${o-.25*n},${h} ${o+.25*n},${h}`).attr("style",`fill: ${r}`),i.label&&e.plain(i.label).attr({x:o,y:h-.3*n,"text-anchor":"middle"}).attr("style",`fill: ${r}`)}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 Pl(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new Pl(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new Pl(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new Pl(-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()===Al.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 oc{constructor(t=2,i=1,s){this.percent=t,this.decimal=i,this.percentSign=s}}class hc{adapt(t){const i=new oc,s=t=>R.isNumber(t)&&Number.isInteger(t)&&t>=0&&t<=100;return s(t.percent)&&(i.percent=t.percent),s(t.decimal)&&(i.decimal=t.decimal),!1===t.percentSign&&(i.percentSign=!1),i}default(){return new oc}}const ac=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:I.ASC},this.level=j.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.parentDimensions={width:0,height:0},l(this)}getDb(){return this.stores||(this.stores=u(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(),wi(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new rc(new se(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 Ol(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 se(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 Ol(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 rc(new se(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(Ql,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=ic({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(Ql,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Ql,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=M(t,this.tableName,this.filter);return this.measureScaleError=void 0,new Cl(new Dl,new st(new Tl),new Tl,new hc,t,i,(t=>{this.measureScaleError=yi(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,sums:this.sums,sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:this.scenarioLabelTop,hideScenarioName:this.hideScenarioName,referenceLine:this.referenceLine,italicCategories:this.italicCategories})}prepareStyle(){var t,i;const s=new Ul(new Gl,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};ac.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 lc=class{validateFilter(t){const i="ERR_filter";p(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(qt(t)||H(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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";rt(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)||ot(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";!T(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=K(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";L(t)||ht(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";q(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){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const s=`WARN_${t}`;!T(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(s)}validateTotalColumn(t){const i="WARN_totalColumn";L(t)||null!=this.parseTotalColumn(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:'totalColumn: needs JSON with a unitScaling greater than 0, for example {"unitScaling":280}.'})}parseTotalColumn(t){try{const i=JSON.parse(t),s=ei(null==i?void 0:i.unitScaling,this.pixelPerUnitGroupMap);if("value"!==s.kind||!(s.value>0))return null;const e=Number(i.width),n="string"==typeof i.label||"number"==typeof i.label?String(i.label):"";return{unitScaling:s.value,label:n,width:e>0?e:1}}catch(t){return null}}prepareTotalColumn(){const t=L(this.totalColumn)?null:this.parseTotalColumn(this.totalColumn),i="WARN_totalColumn_unitScaling";return null==t?(this.errors.remove(i),null):"value"!==ei(this.unitScaling,this.pixelPerUnitGroupMap).kind?(this.errors.addOrReplace({id:i,type:"warning",message:"totalColumn: needs a fixed unitScaling of the chart, the total column is not drawn."}),null):(this.errors.remove(i),{pixelPerUnit:this.getEffectiveFontPx()/t.unitScaling,label:t.label,width:t.width})}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!T(t)||Number(t)<1?this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsStep: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateAxisTitlePosition(t){const i="WARN_axisTitlePosition";L(t)||["left","right","none"].includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisTitlePosition: invalid value '"+t+"' 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.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.dataFormatPercentSign=!0,this.axisLabelsStep=1,this.totalColumn="",this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this._baseHeightBonus=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: ${lc.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${ni(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: ${lc.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(this).t,this.resolveInherited=ri(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),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateAxisLabelsStep(this.axisLabelsStep),this.validateTotalColumn(this.totalColumn),this.validateAxisTitlePosition(this.axisTitlePosition)}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=Xt(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 _(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===ei(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=ii(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)`),_(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(){Bs(this.element,"bn-chart-time-renderer");const t=this.updateBaseHeightBonus();t&&!this._autoScaleGuard&&n(this);const{mode:i}=ii(this.scale);if("auto"!==i&&"empty"!==i)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,this.checkOverflow(),void(t&&n(this));const s=this.element,{width:e}=Xt(s);if(e<=0)return void this.checkOverflow();this._lastObservedWidth=e;const o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),h=s.scrollWidth,a=this.appliedScaleFactor;if(h<=e+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,a*(e-1)/h);Math.abs(l-a)<.01||(s.style.setProperty("--bn-font-size",o*l+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${l.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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)}updateBaseHeightBonus(){var t,i;const s=this.prepareSegments();let e=0;if("value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind&&s.length>1&&0===s[0].length){const n=Array.from(null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer"))&&void 0!==i?i:[]);e=function(t,i){let s=0;for(const e of i)e>0&&(s+=t-e);return Math.max(0,s)}(this.segmentShare(this._lastAppliedHeight,s.length),n.slice(1).map((t=>t.offsetHeight)))}const n=function(t,i){const s=i-t;return s<-1||s>8?i:t}(this._baseHeightBonus,e);return n!==this._baseHeightBonus&&(this._baseHeightBonus=n,!0)}segmentShare(t,i){const s=this.showMeasureScale?this.getEffectiveFontPx():0;return Math.max(0,t-s)/Math.max(1,i)}prepareDimension(t=!1){const i=Xt(this.element),s=this.prepareScenarios(),e=this.prepareSegments();this.canvasWidthSegmented=i.width/(s.length+this.prepareVariances().length||1),this._lastAppliedHeight=i.height;const n=this.segmentShare(i.height,e.length);return{width:this.canvasWidthSegmented,height:n+(t?this._baseHeightBonus:0)}}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()));if(H(n.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return L(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())))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&H(t.value)}prepareSegments(){const t=this.hidesScenarios()?[]:[[]],i=new Map;for(const s of this.prepareVariances()){const e=new Xs(s),n=`${e.type}:${e.delta}`,r=this.scenarioSwitch&&e.isValid?i.get(n):void 0;if(r){r.push(s);continue}const o=[s];t.push(o),e.isValid&&i.set(n,o)}return t}prepareAxisTitlePosition(){var t;const i=null===(t=this.axisTitlePosition)||void 0===t?void 0:t.trim().toLowerCase();return"right"===i||"none"===i?i:"left"}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return L(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 Xs(i);if(t.isValid)for(const n of[t.base,t.delta])s.includes(n)||e.push(`'${i}' needs '${n}'`)}!this.hidesScenarios()&&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=g,i=new Map(["no-data","date-format-short-year"].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(),...ie(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=ei(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: ${lc.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=ei(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: ${lc.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){if(this.syncSpaceLeft>-1)return this.syncSpaceLeft;const s="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return Oa.getMaxWidthOfArrayItems([...s,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return L(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}`}),at[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?at.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),at[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 lt[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase().replace("-","_")]}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 L(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(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios",e="WARN_stack_scenarios_max",n=this.prepareScenarios();return i===Q.DIMENSIONS&&n.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${n[0]}" is used, the rest (${n.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s),i===Q.SCENARIOS&&n.length>4?this.errors.addOrReplace({id:e,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${n.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(e),{by:i,mode:t.mode||tt.ABSOLUTE,order:t.order||Z.DATASET,notation:"scenario"===t.notation?"scenario":"none",legend:["right","both","none"].includes(t.legend)?t.legend:"left",percentMark:!0===t.percentMark}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?ct.LINE:"auto"===i?ct.AUTO:ct.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=Xt(this.element).width,o=this.preparePixelPerUnit(),h=this.preparePixelPerPercentage(),a=this.prepareStackConfig(),l=0===t.length,c=this.hidesScenarios()?qs(t):this.prepareScenarios(),u=l&&(null==a?void 0:a.by)===Q.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return i("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:u,variances:t.length>0?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(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal,percentSign:!1!==this.dataFormatPercentSign},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scalingIndicator:Number(this.scalingIndicator)||0,totalColumn:this.prepareTotalColumn(),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:r,parentDimensions:this.prepareDimension(l),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return rs(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=di(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=ws(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-time-renderer"),f={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:li(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:ai(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=ei(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=ei(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}=ii(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(){this.checkVarianceScenarios(this.prepareVariances());const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const e=this.getFontStyles();return i(s,{key:"c54e501bbea51b366b8a07e578b6cdecec662477",style:e},i("div",{key:"c232324e6c09f86881f60b5af9e84d4a80e49bd2",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}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totalColumn:[{validateTotalColumn:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}}};lc.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 cc{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 uc{adapt(t){const i=new cc;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 cc}}class dc{constructor(t,i,s,e,n,r,o){this.categoryPosition={x:0,y:0},this.spacings=new cc,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*wa("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 fc{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 vc{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 pc{constructor(t){this.container=new Eh,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()}}function gc(t,i,s){const e=t.root();if(!e)return null;const n=`pattern-hatch-${i}-${s}`.replace(/[^a-zA-Z0-9-]/g,"");return e.findOne(`#${n}`)||e.pattern(10,10,(t=>{t.rect(10,10).fill(s),t.line(0,5,5,0).stroke({width:1,color:i,linecap:"square"}),t.line(5,10,10,5).stroke({width:1,color:i,linecap:"square"})})).id(n)}class mc{constructor(t,i,s,e){this.percentClamp=mc.PERCENT_CLAMP,this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?Js(e,null,!0):e;this.variance="neg"===n||n===Sc.NEG?Sc.NEG:"pos"===n||n===Sc.POS?Sc.POS:Sc.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>this.percentClamp?this.percentClamp*this.pixelPerUnit:this.value<-this.percentClamp?-this.percentClamp*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Sc.NEU===this.variance?Sc.NEU:Sc.POS===this.variance?Sc.NEG:Sc.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>this.percentClamp}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}mc.PERCENT_CLAMP=1.45;class bc{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 yc{constructor(){}adapt(t){const i=new bc;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=w.fromISO(t,{zone:"utc"});if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' - skipping row`)}default(){return new bc}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 wc{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 xc{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 wc(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 vc(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new wc(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var Sc,$c;!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"}(Sc||(Sc={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}($c||($c={}));class Mc{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.titlePosition=t.titlePosition||"left",this.titleX=t.titleX,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){var s;null==i&&(i=""),"right"!==this.titlePosition?t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative)):t.text(i).addClass(this.CSS_AXIS_TITLE).move(null!==(s=this.titleX)&&void 0!==s?s:this.position.getAxisEndPositionX()+this.position.spacings.labelToColumn,this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&"none"!==this.titlePosition&&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 _c{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,e,n,r;if(this.isEmpty())return this;const o=this.getScenarioStyle();let h=this.convertToSVGStyle(o,"stroke"),a=this.getFillStyle(o);if(this.isVarianceColumn&&"pl"===this.dataPoint.notation){const t=Number(null===(e=null===(s=this.columnBarStyles)||void 0===s?void 0:s.pl)||void 0===e?void 0:e.width);h={color:(null==o?void 0:o.fill)||this.FALLBACK_COLOUR,width:t>0?t:1},a=this.styles.fontStyles.background||"#ffffff"}if(this.isVarianceColumn&&"fc"===this.dataPoint.notation){const t=(null==o?void 0:o.fill)||this.FALLBACK_COLOUR,i=gc(this.scenarioGroup,t,this.styles.fontStyles.background||"#ffffff");i&&(h={color:t,width:1},a=i)}this.scenarioGroup.attr(as(this.dataPoint.key)),null===(n=this.columnGroup)||void 0===n||n.attr(as(this.dataPoint.key,"element")),this.dataPoint.key&&Number.isFinite(this.dataPoint.value)&&(null===(r=this.columnGroup)||void 0===r||r.attr("data-bn-value",this.dataPoint.value)),null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(a,h):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(a).stroke(h).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=ka.Bottom;null!=t.value&&t.value<0&&(i=ka.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,ka.Center).setPoint(t.key)}getScenarioLabel(t){return new Ta(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,ka.Center,this.isPrimaryColumn?ka.Left:ka.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 kc{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(as(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(as(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 Ta(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,ka.Center,s?ka.Right:ka.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 Oc{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 Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,r?et:s.value,this.styles,ka.Center,ka.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(t={percent:2,decimal:1}){var i,s,e;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.dataLabel)||void 0===s||s.draw(!0,t),this;if(this.isEmpty())return this;this.scenarioGroup.attr(as(this.dataPoint.key)),this.barGroup.attr(as(this.dataPoint.key,"element"));const n=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const h=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),a=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),l=this.barStyles[this.dataPoint.getScenario()];if(null!=l&&l.fillpattern){const t=this.styles.pattern.get(l.fillpattern);null!=t&&(o=t.pattern)}if("pl"===this.dataPoint.notation&&(r.color=(null==n?void 0:n.fill)||r.color,r.width=Math.max(1,Number(r.width)||0),o=this.styles.fontStyles.background||"#ffffff"),this.dimensions.clipped)this.createClippedNeedleHead(o,r);else if("fc"===this.dataPoint.notation){const t=gc(this.barGroup,h.color,this.styles.fontStyles.background||"#ffffff");this.createNeedleHead(null!=t?t:h,{color:h.color,width:1})}else this.createNeedleHead(h,a);this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(o).stroke(r),null===(e=this.dataLabel)||void 0===e||e.draw(!0,t)}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}}class Nc{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 xi[e]||xi.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(as(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?[Ca.Below,Ca.Left,Ca.Right,Ca.Above]:[Ca.Above,Ca.Left,Ca.Right,Ca.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=ka.Bottom,c=ka.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 Ta(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 Ta(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,ka.Center,ka.Left).forceStringTypeDraw()}}class Ac{constructor(t,i,s,e,n,r,o,h,a,l,c,u=!1,d=!1){this.notation=u,this.plainShares=d,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){var s,e;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const n=this.dataPoint.value,r=this.dataPoint.pixelPerUnit,o=this.position.getColumnPositionY(),h=Math.abs(this.segment.end-this.segment.start)*r,a=o-Math.max(this.segment.start,this.segment.end)*r,l=this.position.getColumnCenterPositionX(this.index),c=this.position.getColumnWidth(),u=this.styles.stackColors;let d=u[this.segmentIndex%u.length],f={color:d},v={color:d,width:.5},p=!1;const g=Sa(null!==(s=this.dataPoint.scenario)&&void 0!==s?s:"");if(this.notation&&("fc"===g||"pl"===g)){const t=this.styles.barStyles.getSVGStyle(g);0===this.segmentIndex&&(d=t.fill),f={color:d},v={color:t.stroke,width:1},"hatched"===t.fillpattern&&(p=!0,f=null!==(e=this.hatchPattern(d,t.stroke))&&void 0!==e?e:f)}if(this.columnGroup.attr(as(this.dataPoint.key,"element")),this.columnGroup.attr("data-bn-value",n),this.columnGroup.rect(c,Math.max(h,.5)).fill(f).stroke(v).y(a).cx(l),h>=Math.min(18,1.15*(this.styles.fontStyles.size||18))){const s=a+h/2,e=t=>p?t:t.setSegmentFill(d);if(this.stackMode===tt.RELATIVE||this.stackMode===tt.ABSOLUTE_RELATIVE){const i=this.plainShares?Oa.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):Oa.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);e(new Ta(this.group,l,s,"STACK_SEG",i,this.styles,ka.Center,ka.Center)).setPoint(this.dataPoint.key).forceStringTypeDraw()}else e(new Ta(this.group,l,s,"STACK_SEG",n,this.styles,ka.Center,ka.Center)).setPoint(this.dataPoint.key).draw(!0,t,i)}}hatchPattern(t,i){const s=this.group.root();if(!s)return null;const e=`pattern-stack-fc-${this.segmentIndex}`;return s.findOne(`#${e}`)||s.pattern(10,10,(s=>{s.rect(10,10).fill(t),s.line(0,5,5,0).stroke({width:1,color:i,linecap:"square"}),s.line(5,10,10,5).stroke({width:1,color:i,linecap:"square"})})).id(e)}drawTotalLabel(t={percent:2,decimal:1},i=new La,s){if(this.stackMode===tt.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 Ta(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,e?ka.Top:ka.Bottom,ka.Center).setPoint(s,"total").draw(!0,t,i)}}const Rc=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class Lc{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=Si[s]||Si.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,Rc.length-1);t=Rc[s].fill,i=Rc[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=Si[s]||Si.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 Tc{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=ka.Bottom;return null!=t.value&&t.value<0&&(i=ka.Top),new Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,ka.Center)}getScenarioLabel(t){return new Ta(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,ka.Bottom,ka.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 Ec{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 Tc(this.position,this.styles,i,s,e,!1,n,o).updateLabelGroup(r)}createPrimaryBar(t,i,s=!0){const e=this.svgGroups.scenario1.group().id(""+i),n=this.svgGroups.scenario1Label.group().id(""+i);let r=null;return s&&this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new _c(this.position,this.styles,t,i,!0,e,r,this.overflowConfig).updateLabelGroup(n)}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 _c(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 Oc(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i,s=!0){const e=this.svgGroups.scenario2.group().id(""+i);let n=null;return s&&this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new _c(this.position,this.styles,t,i,!1,e,n,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 kc(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 kc(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 Nc(this.position,this.styles,t,e,n,i,r,this.i18n,this.collisionManager,s)}}const Cc="bn-measurement-host";function Pc(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(Cc);return t||(t=document.createElement("div"),t.id=Cc,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 Wc,Dc;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Wc||(Wc={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Dc||(Dc={}));const zc="#c5dbf2";class Uc{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 mc(0,Sc.AC1,1,Sc.NEU),this.highestDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.smallestVarianceDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.highestVarianceDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Sc.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=Wc.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=at.DAY,this.locale="de",this.axisLabelsMode=lt.SMART,this.intervalSpanLimit=32,this.measureScale=new La,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=ct.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.axisLabelsStep=1,this.scalingIndicator=0,this.totalColumn=null,this.totalVariance=null,this.highestColumnDataPointValue=new mc(0,"default",0,Sc.NEU),this.highestPeriodVarianceDataPointValue=new mc(0,"default",0,Sc.NEU),this.scenarioSwitch=!1,this.axisTitlePosition="left",this.varianceOverlaps=0,this.db=i,this.tableName=s,this.ruleSet=t||new se,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 se}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===ct.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestPeriodVarianceDataPointValue:this.highestColumnDataPointValue).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+this.switchNamesHeight())-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,s,e,n,r,o,h;this.state=Wc.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const a=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.axisLabelsStep=null!==(i=t.axisLabelsStep)&&void 0!==i?i:1,this.scalingIndicator=null!==(s=t.scalingIndicator)&&void 0!==s?s:0,this.totalColumn=null!==(e=t.totalColumn)&&void 0!==e?e:null,this.scenarioSwitch=null!==(n=t.scenarioSwitch)&&void 0!==n&&n,this.axisTitlePosition=null!==(r=t.axisTitlePosition)&&void 0!==r?r:"left",this.dateInterval=this.findDateInterval(t.dateInterval),this.stackConfig=t.stackConfig,this.dataModel=this.populateModel(a,this.dateInterval),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(o=null==t?void 0:t.variances)&&void 0!==o?o:[],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=a,null!=this.stackConfig){const t=[];for(const i of this.dataModel)t.push(...this.stackGroups(i).map((t=>t.layout)));const i=ec(t),{reference:s}=this.seriesSlots();if(s)for(const t of this.dataModel){const e=null===(h=t[s])||void 0===h?void 0:h.value;Number.isFinite(e)&&(i.positive=Math.max(i.positive,e),i.negative=Math.max(i.negative,-e))}const{scenario:e,variance:n}=this.highestDataPointValue;this.highestDataPointValue=new mc(i.positive,e,this.pixelPerUnit,n),this.smallestDataPointValue=new mc(0-i.negative,e,this.pixelPerUnit,n)}if(this.highestColumnDataPointValue=this.highestDataPointValue,this.highestPeriodVarianceDataPointValue=this.highestVarianceDataPointValue,this.totalVariance=this.totalVariancePoint(),null!=this.totalVariance&&Number.isFinite(this.totalVariance.value)&&(this.totalVariance.value>Number(this.highestVarianceDataPointValue.value)&&(this.highestVarianceDataPointValue=this.totalVariance),this.totalVariance.value<Number(this.smallestVarianceDataPointValue.value)&&(this.smallestVarianceDataPointValue=this.totalVariance)),this.hasScalingIndicator()&&this.scalingIndicator>Number(this.highestDataPointValue.value)){const{scenario:t,variance:i}=this.highestDataPointValue;this.highestDataPointValue=new mc(this.scalingIndicator,t,this.pixelPerUnit,i)}const l=this.isVarianceChart()?0:this.totalColumnHeight();if(l>this.highestDataPointValue.getScaledUnit()&&this.pixelPerUnit>0){const{scenario:t,variance:i}=this.highestDataPointValue;this.highestDataPointValue=new mc(l/this.pixelPerUnit,t,this.pixelPerUnit,i)}this.updateTitle(),this.updatePosition(a)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Oa.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,i,s;let e=this.scenarioSwitch?null===(t=this.configVariances)||void 0===t?void 0:t[0]:null===(i=this.configVariances)||void 0===i?void 0:i.toString();if(this.scenarioSwitch&&e){const t=new Xs(e),i=null===(s=this.dataModel)||void 0===s?void 0:s[0],n=["scenario1","scenario2","scenario3","scenario4"].find((s=>{var e;return(null===(e=null==i?void 0:i[s])||void 0===e?void 0:e.scenario)===t.base}));t.isValid&&null!=n&&("scenario1"===n||this.followerSlots().includes(n))&&(e=`${t.type}ac1_${t.delta}_${t.direction}`)}this.title=this.configTitle||Oa.translateScenarioLabel(e,this.i18n)}setSource(t){var i,s;if(this.state=Wc.DIRTY,this.queryError=void 0,this.fromExpr=M(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=yi(t))}getAllocatedCanvasWidth(){var t;const i=this.position.getAxisEndPositionX(),s=3*this.styles.fontStyles.size,e=Math.max(this.axisCategoryArea.width,this.scenariosArea.width),n=e>0?e+this.position.leftSideLabelLength:0;let r=0;if("right"===this.axisTitlePosition&&this.title){const s=wa(this.title,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;r=(null!==(t=this.rightTitleX())&&void 0!==t?t:i+this.position.spacings.labelToColumn)+s+this.styles.padding.right}const o=this.legendWidth("right"),h=o>0?i+this.position.spacings.labelToColumn+o+this.styles.padding.right:0;let a=0;if(this.hasScalingIndicator()){const t=wa(this.scalingIndicatorText(),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;a=this.scalingIndicatorLabelX()+t+this.styles.padding.right}const l=this.hasTotalColumn()?this.totalColumnGeometry().right+this.totalColumnTextWidth()+this.styles.padding.right:0;return Math.max(i+s,n,r,h,a,l)}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===Dc.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)+this.switchNamesHeight()}switchNamesHeight(){return!this.hideAxisLabels&&this.contextRow().length>0?this.position.dataLabelHeight:0}parentPeriodLabel(t){if(this.axisLabelsMode!==lt.TWO_ROW||null==t||!t.isValid)return"";switch(this.dateInterval){case at.MONTH:case at.QUARTER:return t.setLocale(this.locale).toFormat("yyyy");case at.WEEK:return t.setLocale(this.locale).toFormat("kkkk");case at.DAY:return t.setLocale(this.locale).toFormat("LLL yyyy");default:return""}}contextRow(){const t=this.switchRuns();if(this.axisLabelsMode!==lt.TWO_ROW)return t.map((t=>({from:t.from,to:t.to,text:Oa.translateScenarioLabel(t.scenario,this.i18n),scenario:t.scenario})));if(!this.isVarianceChart()&&this.determineEffectiveChartMode()!==ct.BAR)return[];const i=this.isVarianceChart()?this.variancesDataModel:this.dataModel,s=[];let e="";return i.forEach(((i,n)=>{var r;const o=t.find((t=>t.from===n)),h=this.parentPeriodLabel(i.date),a=[];""!==h&&h!==e&&a.push(h),e=h,o&&a.push(Oa.translateScenarioLabel(o.scenario,this.i18n)),a.length>0&&s.push({from:n,to:n,text:a.join(" "),scenario:null!==(r=null==o?void 0:o.scenario)&&void 0!==r?r:"parent"})})),s}static hasValue(t){return null!=t&&!t.isEmpty()&&null!=t.value&&!Number.isNaN(t.value)}static hasAmount(t){return null!=t&&Number.isFinite(t.value)&&0!==t.value}followerSlots(){return!this.scenarioSwitch||null!=this.stackConfig&&this.stackConfig.by!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR?[]:["scenario2","scenario3","scenario4"].filter((t=>{let i=0;for(const s of this.dataModel)if(Uc.hasValue(s[t])){if(Uc.hasValue(s.scenario1))return!1;i++}return i>0}))}visibleSlot(t,i){var s;return Uc.hasValue(t.scenario1)?"scenario1":null!==(s=i.find((i=>Uc.hasValue(t[i]))))&&void 0!==s?s:null}switchRuns(){if(!this.scenarioSwitch||null!=this.stackConfig&&this.stackConfig.by!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR)return[];const t=this.followerSlots();if(0===t.length&&1!==this.scenarioPropOrder.length)return[];const i=[];return this.dataModel.forEach(((s,e)=>{const n=this.visibleSlot(s,t),r=n?s[n].scenario:null,o=i[i.length-1];null!=r&&(null==o?void 0:o.scenario)!==r?i.push({scenario:r,from:e,to:e}):o&&(o.to=e)})),i}seriesSlots(){var t,i,s;if(!this.scenarioSwitch||(null===(t=this.stackConfig)||void 0===t?void 0:t.by)!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR)return{fill:[],reference:null};const e=this.followerSlots(),n=t=>Uc.hasAmount(t),r=[];let o=null;for(const t of["scenario2","scenario3","scenario4"]){if(e.includes(t))continue;let h=0,a=!1;for(const r of this.dataModel){const o=null!==(i=this.visibleSlot(r,e))&&void 0!==i?i:"scenario1";for(const i of null!==(s=r.series)&&void 0!==s?s:[])n(i.points[t])&&(h++,a=a||n(i.points[o]))}0!==h&&(a?null==o&&this.stackConfig.mode!==tt.RELATIVE&&(o=t):r.push(t))}return{fill:r,reference:o}}getIgnoredSwitchScenarios(){var t;if(!this.scenarioSwitch||(null===(t=this.stackConfig)||void 0===t?void 0:t.by)!==Q.DIMENSIONS||this.isVarianceChart())return[];const i=this.followerSlots(),{fill:s,reference:e}=this.seriesSlots(),n=[...i,...s,e];return["scenario2","scenario3","scenario4"].filter((t=>!n.includes(t)&&this.dataModel.some((i=>Uc.hasValue(i[t]))))).map((t=>{var i;return null===(i=this.dataModel.find((i=>{var s;return null!=(null===(s=i[t])||void 0===s?void 0:s.scenario)})))||void 0===i?void 0:i[t].scenario}))}getVarianceOverlaps(){return this.varianceOverlaps}fitRelativeVariances(t){const i=this.variancesDataModel.filter((t=>t.type===Dc.RELATIVE)).map((t=>t.scenario1));if(i.length>0&&null!=this.totalVariance&&i.push(this.totalVariance),0===i.length||!i.some((t=>t.isClipped())))return;const s=t=>{i.forEach((i=>i.percentClamp=t)),this.updatePosition(this.lastScenarios)};s(Number.POSITIVE_INFINITY),this.layout(),t>0&&this.getAllocatedCanvasHeight()<=t||s(mc.PERCENT_CLAMP)}getUnitBarExtent(){var t,i;const s=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===Dc.RELATIVE)),e=this.isVarianceChart(),n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Zl({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 tc({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===Dc.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 Eh;Pc(t,(()=>this.draw(t)))}toString(){const t=new Eh;return Pc(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===Wc.DIRTY&&(this.state=Wc.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawTotalVariance(t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===ct.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.drawScalingIndicator(t)):this.determineEffectiveChartMode()===ct.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),this.drawScalingIndicator(t),this.drawTotalColumn(t))}hasScalingIndicator(){var t,i;return this.scalingIndicator>0&&!this.isVarianceChart()&&(null!==(t=this.configVariances)&&void 0!==t?t:[]).every((t=>!t))&&this.determineEffectiveChartMode()===ct.BAR&&(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE}scalingIndicatorText(){var t,i,s;const e=null!==(i=null===(t=this.dataFormatDigits)||void 0===t?void 0:t.decimal)&&void 0!==i?i:1;return Oa.number(this.scalingIndicator,"decimal",e,e,(null===(s=this.measureScale)||void 0===s?void 0:s.value)||1,this.styles.locale)}scalingIndicatorTextWidth(){return wa(this.scalingIndicatorText(),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}scalingIndicatorLabelX(){const t=this.position.spacings.labelToColumn,i=this.position.getColumnWidth()/2+this.position.spacings.scenarioOffset,s=this.position.getColumnCenterPositionX(Math.max(0,this.dataModel.length-1))+i,e=this.legendWidth("right");return s+t+(e>0?e+t:0)}scalingIndicatorBand(){if(!this.hasScalingIndicator()||0===this.dataModel.length)return null;const t=this.position.getColumnWidth()/2+this.position.spacings.scenarioOffset,i=this.scalingIndicator*this.pixelPerUnit;return this.overflowConfig&&i>this.overflowConfig.cutHeight?null:{left:this.position.getColumnCenterPositionX(0)-t,right:this.position.getColumnCenterPositionX(this.dataModel.length-1)+t,height:i}}drawScalingIndicator(t){const i=this.scalingIndicatorBand();if(null==i)return;const{left:s,right:e,height:n}=i,r=this.position.getColumnPositionY(),o=t.group().id("ScalingIndicator");o.rect(e-s,n).x(s).y(r-n).fill(zc),o.back(),new Ta(t.group().id("ScalingIndicatorLabel"),this.scalingIndicatorLabelX(),r-n,"SCALING_INDICATOR",this.scalingIndicatorText(),this.styles,ka.Center,ka.Left).forceStringTypeDraw()}rightTitleX(){if(this.hasTotalColumn())return this.totalColumnGeometry().right+this.totalColumnTextWidth()+this.position.spacings.labelToColumn}hasTotalColumn(){return null!=this.totalColumnParts()}totalColumnGeometry(){var t,i;const s=this.position.getColumnWidth(),e=s*(null!==(i=null===(t=this.totalColumn)||void 0===t?void 0:t.width)&&void 0!==i?i:1),n=this.position.getColumnCenterPositionX(this.dataModel.length+1)+(e-s)/2,r=this.position.spacings.scenarioOffset,o=n+(this.scalingIndicator>0?this.scalingIndicatorTextWidth()+r:0);return{center:o,width:e,left:o-e/2-2*r,right:o+e/2+r}}totalColumnParts(){var t;if(null==this.totalColumn||null!=this.stackConfig||0===this.dataModel.length||this.determineEffectiveChartMode()!==ct.BAR)return null;const i=this.followerSlots(),s=new Map;for(const e of this.dataModel){const n=this.visibleSlot(e,i),r=n?e[n]:null;if(null==n||!Number.isFinite(null==r?void 0:r.value))continue;const o=null!==(t=s.get(n))&&void 0!==t?t:{scenario:r.scenario,value:0};o.value+=r.value,s.set(n,o)}const e=[...s.values()];if(0===e.length||e.some((t=>!(t.value>0))))return null;let n=null;for(const t of["scenario2","scenario3","scenario4"]){if(i.includes(t))continue;const s=this.dataModel.map((i=>i[t])).filter((t=>Number.isFinite(null==t?void 0:t.value)));if(s.length>0){n={scenario:s[0].scenario,value:s.reduce(((t,i)=>t+i.value),0)};break}}return{parts:e,height:e.reduce(((t,i)=>t+i.value),0),total:e.reduce(((t,i)=>t+i.value),0),reference:n}}totalColumnHeight(){var t,i;const s=this.totalColumnParts();if(null==s)return 0;const e=this.hasScalingIndicator()?this.scalingIndicator:0;return Math.max(s.height,null!==(i=null===(t=s.reference)||void 0===t?void 0:t.value)&&void 0!==i?i:0,e)*this.totalColumn.pixelPerUnit}totalVariancePoint(){var t,i,s,e,n,r;if(!this.hasTotalColumn()||!this.isVarianceChart())return null;const o=null!==(t=this.dataModel[0])&&void 0!==t?t:null,h=(null!==(i=this.configVariances)&&void 0!==i?i:[]).map((t=>({name:t,variance:new Xs(t)}))).filter((t=>t.variance.isValid));if(0===h.length)return null;let a=0,l=0;const c=new Set;for(const t of this.dataModel)for(const{variance:i}of h){const h=this.mapScenarios(i,o),u=null===(e=t[null!==(s=h.get(i.base))&&void 0!==s?s:""])||void 0===e?void 0:e.value,d=null===(r=t[null!==(n=h.get(i.delta))&&void 0!==n?n:""])||void 0===r?void 0:r.value;if(Number.isFinite(u)&&Number.isFinite(d)){a+=u,l+=d,c.add(i.base.slice(0,2));break}}if(0===c.size)return null;const u=h[0].variance,d=u.type===Dc.RELATIVE,f=new mc(d?nt(a-l,l):a-l,u.delta,d?this.pixelPerPercentage:this.pixelPerUnit,u.direction);return this.scenarioSwitch&&(f.notation=c.has("fc")?"fc":1===c.size?[...c][0]:"ac"),f.key={row:"total",scenario:h[0].name},f}totalColumnTextWidth(){const t=t=>wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,i=this.position.spacings.labelToColumn,s=this.totalColumnParts();let e=0;return null!=s&&s.parts.length>1&&(e=i+Math.max(...s.parts.map((i=>t(this.scenarioName(i.scenario)))))),e+(null!=s&&this.hasScalingIndicator()?i+t(this.scalingIndicatorText()):0)}scenarioName(t){return this.i18n.get(t)||t}columnLook(t){var i,s;const e=null!==(i=this.scenarioStyles().barStyles[Sa(t)])&&void 0!==i?i:{},n=e.fillpattern?null===(s=this.styles.pattern.get(e.fillpattern))||void 0===s?void 0:s.pattern:void 0,r=e.fill||"#404040";return{fill:null!=n?n:r,stroke:{color:e.stroke||r,width:Number(e.width)||0},solid:n?null:r}}drawTotalAxis(t,i){const{left:s,right:e}=this.totalColumnGeometry(),n=null==this.axisScenario?"default":`${this.axisScenario}`.slice(0,2);t.line(s,i,e,i).addClass("axis-"+n)}drawTotalColumn(t){const i=this.isVarianceChart()?null:this.totalColumnParts();if(null==i)return;const{center:s,width:e,left:n,right:r}=this.totalColumnGeometry(),o=this.totalColumn.pixelPerUnit,h=this.position.getColumnPositionY(),a=this.position.spacings.labelToColumn,l=t.group().id("TotalColumn");if(this.hasScalingIndicator()){const t=this.scalingIndicator*o,i=this.scalingIndicatorBand();if(l.rect(r-n,t).x(n).y(h-t).fill(zc),null!=i){const s=this.scalingIndicatorLabelX()+this.scalingIndicatorTextWidth()+a/2;l.line(Math.min(s,n),h-i.height,n,h-t).stroke({color:"#5b9bd5",width:1}).id("ScalingIndicatorLink")}}if(null!=i.reference&&i.reference.value>0){const t=this.columnLook(i.reference.scenario),n=i.reference.value*o;l.rect(e,n).cx(s-this.position.spacings.scenarioOffset).y(h-n).fill(t.fill).stroke(t.stroke).attr(as({row:"total",scenario:i.reference.scenario},"element")).attr("data-bn-value",i.reference.value)}let c=h;const u=t.group().id("TotalColumnLabels");for(const t of i.parts){const n=this.columnLook(t.scenario),r=t.value*o;c-=r;const d={row:"total",scenario:t.scenario};if(l.rect(e,r).cx(s).y(c).fill(n.fill).stroke(n.stroke).attr(as(d,"element")).attr("data-bn-value",t.value),i.parts.length>1){if(r>=this.position.dataLabelHeight){const i=new Ta(u,s,c+r/2,"TOTAL_PART",t.value,this.styles,ka.Center,ka.Center).setPoint(d);(n.solid?i.setSegmentFill(n.solid):i).draw(!0,this.dataFormatDigits,this.measureScale)}new Ta(u,s+e/2+a,Math.max(c+r/2,h-i.height*o+this.position.dataLabelHeight/2),"TOTAL_NAME",this.scenarioName(t.scenario),this.styles,ka.Center,ka.Left).forceStringTypeDraw()}}new Ta(u,s,c-a,"TOTAL",i.total,this.styles,ka.Bottom,ka.Center).setPoint({row:"total"},"total").draw(!0,this.dataFormatDigits,this.measureScale),this.drawTotalAxis(l,this.position.getAxisPositionY(!1)),this.hasScalingIndicator()&&new Ta(u,r+this.totalColumnTextWidth()-wa(this.scalingIndicatorText(),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,h-this.scalingIndicator*o,"SCALING_INDICATOR_TOTAL",this.scalingIndicatorText(),this.styles,ka.Center,ka.Left).forceStringTypeDraw(),!1===this.hideAxisLabels&&this.totalColumn.label&&new Ta(u,s,this.position.getAxisPositionY(!1)+this.position.spacings.labelToAxis,"TOTAL_LABEL",this.totalColumn.label,this.styles,ka.Top,ka.Center).forceStringTypeDraw()}drawTotalVariance(t){var i;const s=this.totalVariance;if(null==s)return;const e=null!==(i=t.findOne("#Scenarios"))&&void 0!==i?i:t.group().id("Scenarios"),n=e.group().id("TotalColumn"),r=e.group().id("TotalColumnLabels"),{center:o}=this.totalColumnGeometry(),h=(o-this.position.getColumnCenterPositionX(0))/(this.position.getColumnCenterPositionX(1)-this.position.getColumnCenterPositionX(0)),a=this.variancesDataModel.some((t=>t.type===Dc.RELATIVE));if(a)new Oc(this.position,this.scenarioStyles(),s,h,n.group()).updateLabelGroup(r.group()).draw(this.dataFormatDigits);else{const t=this.overflowConfig?Object.assign(Object.assign({},this.overflowConfig),{maxOverflow:Math.max(this.overflowConfig.maxOverflow,s.getScaledUnit()-(this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset))}):null;new _c(this.position,this.scenarioStyles(),s,h,!0,n.group(),null,t).updateLabelGroup(r.group()).setAsVariance().draw(this.dataFormatDigits,this.measureScale)}this.drawTotalAxis(n,this.position.getAxisPositionY(a));const l=e.bbox();this.scenariosArea={height:l.height+this.styles.padding.top+this.styles.padding.bottom,width:l.width+this.position.spacings.columnWidth}}determineEffectiveChartMode(){return this.chartMode===ct.LINE||this.chartMode===ct.AUTO&&this.dataModel.length>this.maxBars?ct.LINE:ct.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=Wc.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=wa(t.filter(((t,i)=>1===i||2===i)).map((t=>Oa.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),i=Math.max(i,this.legendWidth("left")),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,e=Math.max(t+i+s,this.isVarianceChart()?0:this.totalColumnHeight());r=new mc(e,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===ct.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 cc;Object.assign(s,e),s.categoryWidth=i,o=s}}return new dc(new fc(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=wa(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}scenarioStyles(){const t=te(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=Sc.AC1;if(null!=t&&t.length>0){const s=new Xs(t.toString());s.isValid&&(i=Zs(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=Sc.AC1),i}populateModel(t,i){var s;if(0===this.rowCount||!this.fromExpr)return[];let e=this.queryDataSet(i,"","");this.detectNaNCells(t,e),e=this.leftOuterJoinDates(e,i);const n=this.createDataRows(e,t);return(null===(s=this.stackConfig)||void 0===s?void 0:s.by)===Q.DIMENSIONS&&this.populateSeries(n,t,i),n}populateSeries(t,i,s){const e=this.queryDataSet(s,", [category]",", [category]");this.detectNaNCells(i,e);const n=t=>null==t.category?"":String(t.category),r=t=>{var i,s;return null!==(s=null===(i=null==t?void 0:t.toMillis)||void 0===i?void 0:i.call(t))&&void 0!==s?s:Number.NaN},o=[],h=new Map;for(const t of e){const i=n(t);o.includes(i)||o.push(i);const s=r(t.calcdate);h.has(s)||h.set(s,new Map),h.get(s).set(i,t)}try{const t=this.db.exec(`SELECT [category], MIN(categoryIndex) AS idx FROM ${this.fromExpr} GROUP BY [category]`),i=new Map(t.map((t=>[null==t.category?"":String(t.category),t.idx])));o.every((t=>Number.isFinite(i.get(t))))&&o.sort(((t,s)=>i.get(t)-i.get(s)))}catch(t){}const a=["scenario1","scenario2","scenario3","scenario4"];for(const s of t){const t=h.get(r(s.date));s.series=o.map((e=>{const n=null==t?void 0:t.get(e),r={};return a.forEach(((t,o)=>{const h=i[o];if(null==h)return;const a=null==n?void 0:n[h],l="number"==typeof a?a:Number.NaN,c=new mc(l,h,this.pixelPerUnit,Sc.NEU);Number.isFinite(l)&&(c.key={date:Uc.pointDate(s.date),scenario:h,category:e}),r[t]=c})),{key:e,points:r}}))}}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Xs(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!==at.AUTO)return t;const i=this.queryDates();if(0===i.length)return at.DAY;let s=i[0],e=i[0];for(const t of i)t<s&&(s=t),t>e&&(e=t);return(new ut).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=>Uc.coerceDateTime(t.date))).filter((t=>null!=t))}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=w.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=w.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:Dc.NONE,date:t.calcdate,scenario1:new mc(t[i[0]],i[0],this.pixelPerUnit,Sc.NEU),scenario2:new mc(t[i[1]],i[1],this.pixelPerUnit,Sc.NEU),scenario3:new mc(t[i[2]],i[2],this.pixelPerUnit,Sc.NEU),scenario4:new mc(t[i[3]],i[3],this.pixelPerUnit,Sc.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:Uc.pointDate(t.date),scenario:null!==(s=i.scenario)&&void 0!==s?s:void 0});return e}static pointDate(t){var i;return cs(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 mc(0,"default",i,Sc.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 mc(0,"default",i,Sc.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]),this.varianceOverlaps=0;const n=t.map((t=>new Xs(t)));if(this.scenarioSwitch&&n.filter((t=>t.isValid)).length>1)return this.populateSharedVarianceRow(t,n,i,e);for(const n in t){const r=new Xs(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 mc(this.calculateVariance(r,i[e],o),r.delta,a,h);this.scenarioSwitch&&(l.notation=r.base.slice(0,2)),null===l.value||Number.isNaN(l.value)||(l.key={date:Uc.pointDate(i[e].date),scenario:t[n]}),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Dc.RELATIVE:Dc.ABSOLUTE,date:i[e].date,scenario1:l,scenario2:new mc(null,null,null,null),scenario3:new mc(null,null,null,null),scenario4:new mc(null,null,null,null)})}}}return s}populateSharedVarianceRow(t,i,s,e){const n=[],r=i.map(((i,s)=>({variance:i,name:t[s]}))).filter((t=>t.variance.isValid)),o="dr"===r[0].variance.type,h=o?this.pixelPerPercentage:this.pixelPerUnit;return s.forEach(((t,i)=>{let s=null,a=0;for(const{variance:i,name:n}of r){const r=this.calculateVariance(i,t,this.mapScenarios(i,e));null===r||Number.isNaN(r)||(a++,null==s&&(s=new mc(r,i.delta,h,i.direction),s.notation=i.base.slice(0,2),s.key={date:Uc.pointDate(t.date),scenario:n}))}a>1&&this.varianceOverlaps++,n.push({id:i,category:t.category,type:o?Dc.RELATIVE:Dc.ABSOLUTE,date:t.date,scenario1:null!=s?s:new mc(null,r[0].variance.delta,h,r[0].variance.direction),scenario2:new mc(null,null,null,null),scenario3:new mc(null,null,null,null),scenario4:new mc(null,null,null,null)})})),n}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===Dc.RELATIVE?nt(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 ut;t.setLocale(this.locale);const i=this.i18n.get("date-format-short-year");return"string"==typeof i&&/y/.test(i)&&!i.includes("date-format")&&t.patchDateFormatShort({year:i}),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!==tt.RELATIVE&&this.determineEffectiveChartMode()!==ct.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=nc(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:ka.Bottom,offset:-s}:{hookLocation:ka.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===Dc.RELATIVE&&(n=!0);const h=this.axisLabelsMode===lt.SMART&&s.isSmartBoundary(t.date,this.dateInterval);if(i%this.axisLabelsStep!=0&&!h)return;let a=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===lt.SMART?(a=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==at.YEAR&&(a=s.getShortDateString(t.date,this.dateInterval))):(this.axisLabelsMode===lt.SHORT||this.axisLabelsMode===lt.TWO_ROW&&this.dateInterval!==at.YEAR)&&(a=s.getShortDateString(t.date,this.dateInterval)),new Ta(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+o,"",a,this.styles,r,ka.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===Dc.RELATIVE&&(n=!0)}new Mc({scenarioType:this.axisScenario,labelText:this.title,isRelative:n,titlePosition:this.axisTitlePosition,titleX:this.rightTitleX()},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width},this.drawScenarioSwitch(i)}drawScenarioSwitch(t){const i=this.switchRuns(),s=this.contextRow();if(i.length<2&&0===s.length)return;const e=t.group().id("ScenarioSwitch"),n=this.switchNamesHeight(),r=this.getAllocatedCanvasHeight(),o=n>0?r-this.styles.padding.bottom:r,h=Math.max(1,this.position.spacings.auxiliaryLineWidth);if(i.slice(1).forEach((t=>{const i=(this.position.getColumnCenterPositionX(t.from-1)+this.position.getColumnCenterPositionX(t.from))/2;e.line(i,0,i,o).stroke({color:this.styles.fontStyles.color||"#000000",width:h}).addClass("scenario-switch")})),0===n)return;const a=this.axisLabelsMode===lt.TWO_ROW;s.forEach((t=>{const i=a?this.position.getColumnCenterPositionX(t.from)-this.position.getColumnWidth()/2:(this.position.getColumnCenterPositionX(t.from)+this.position.getColumnCenterPositionX(t.to))/2;new Ta(e,i,o-n,"SWITCH_"+t.scenario+"_"+t.from,t.text,this.styles,ka.Top,a?ka.Left:ka.Center).forceStringTypeDraw()}))}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;const r=this.followerSlots();t.forEach(((t,i)=>{const s=r.length>0?this.visibleSlot(t,r):"scenario1";null!=s&&"scenario1"!==s?(e.createPrimaryBar(t[s],i,!1).draw(this.dataFormatDigits,this.measureScale),n=!0):e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),"scenario2"!==s&&e.createSecondaryBar(t.scenario2,i).draw(),"scenario3"!==s&&e.createPrimaryMarker(t.scenario3,i).draw(),"scenario4"!==s&&e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let o=0;!1===n&&(o=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const h=s.bbox();this.scenariosArea={height:h.height+this.styles.padding.top+this.styles.padding.bottom+o,width:h.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new Pa,o=new Ec(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)=>(Ea[i.scenarioType]||99)-(Ea[t.scenarioType]||99)));const c=[];for(const t of l){const i=o.createLineSeries(t.points,t.scenarioName,Zs(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)=>(Ea[t.scenarioType]||99)-(Ea[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===lt.SMART?(l=s.getSmartDateString(i.date,this.dateInterval),0===o&&this.dateInterval!==at.YEAR&&(l=s.getShortDateString(i.date,this.dateInterval))):l=this.axisLabelsMode===lt.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):l=s.getShortDateString(i.date,this.dateInterval),new Ta(e,this.position.getColumnCenterPositionX(o),this.position.getAxisPositionY(n)+a,"",l,this.styles,h,ka.Center).forceStringTypeDraw(),o>0&&o<r&&this.isYearChange(t,o)&&this.drawYearSeparatorLine(e,o,n)})),new Mc({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===at.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:$i}).attr("stroke-dasharray",$i)}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Dc.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw(this.dataFormatDigits):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){var i;if(!this.stackConfig)return[];const s=this.stackConfig.by===Q.SCENARIOS,e=this.determineEffectiveChartMode()===ct.LINE,n=this.stackConfig.mode===tt.RELATIVE?dt:0,r=t=>Number.isFinite(t.value)?t.value:0,o=t=>{"asc"===this.stackConfig.order?t.sort(((t,i)=>r(t)-r(i))):"desc"===this.stackConfig.order&&t.sort(((t,i)=>r(i)-r(t)))};if(!s&&!e&&t.series){const s=null!==(i=this.visibleSlot(t,this.followerSlots()))&&void 0!==i?i:"scenario1",{fill:e}=this.seriesSlots(),r=[];return t.series.forEach(((t,i)=>{const n=Uc.hasAmount(t.points[s])?void 0:e.find((i=>Uc.hasAmount(t.points[i]))),o=t.points[null!=n?n:s];o&&r.push({value:o.value,scenario:o.scenario,dataPoint:o,colorIndex:i,label:t.key})})),r.some((t=>Number.isFinite(t.value)))?(o(r),[{prefix:"",segments:r,layout:sc(r.map((t=>t.value)),n),hasValue:!0}]):[]}const h=[];for(const i of s?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&h.push({value:s.value,scenario:s.scenario,dataPoint:s})}if(0===h.length)return[];const a=(t,i)=>({prefix:t,segments:i,layout:sc(i.map((t=>t.value)),n),hasValue:i.some((t=>Number.isFinite(t.value)))});if(s&&this.sortSegmentsByPropOrder(h),e)return[a("",h)];if(s){const t=new Map;for(const i of h){const s=Sa(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of xa)t.has(s)&&(i.push(a(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(a(s,e));return i}}return o(h),[a("",h)]}drawStackedScenarios(t,i){var s;if(!this.stackConfig)return;const{reference:e}=this.seriesSlots();if(e){const n=new Ec(this.position,i.group().id("StackReference"),this.scenarioStyles(),t.length,this.i18n),r=null!==(s=this.stackConfig.legend)&&void 0!==s?s:"left",o="left"!==r&&"both"!==r;t.forEach(((t,i)=>n.createSecondaryBar(t[e],i,o).draw()))}const n=i.group().id("StackedScenarios"),r=this.stackConfig.by===Q.SCENARIOS;t.forEach(((t,i)=>{const s=this.stackGroups(t);s.forEach(((e,o)=>{let h=null;e.segments.forEach(((t,a)=>{var l;const c=new Ac(this.position,this.styles,t.dataPoint,i,e.layout.segments[a],t.scenario,s.length>1?s.length-1-o:null!==(l=t.colorIndex)&&void 0!==l?l:a,this.stackConfig.mode,e.layout,r,n,"scenario"===this.stackConfig.notation,this.hasPercentMark());c.draw(this.dataFormatDigits,this.measureScale),h=c})),h&&e.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,{date:Uc.pointDate(t.date),scenario:s.length>1?e.prefix:void 0})}))}));const o=n.bbox();this.scenariosArea={height:o.height+this.styles.padding.top+this.styles.padding.bottom,width:o.width+this.position.spacings.columnWidth}}hasPercentMark(){var t;return(null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===tt.RELATIVE&&!0===this.stackConfig.percentMark}percentMarkSide(){var t;return"right"===(null===(t=this.stackConfig)||void 0===t?void 0:t.legend)?"right":"left"}seriesName(t){return this.i18n.get(t)||t}legendWidth(t){var i,s;if(!this.stackConfig||this.determineEffectiveChartMode()!==ct.BAR)return 0;const e=null!==(i=this.stackConfig.legend)&&void 0!==i?i:"left",n=[];if(e===t||"both"===e){const i=null===(s=this.dataModel.find((t=>null!=t.series)))||void 0===s?void 0:s.series;i?n.push(...i.map((t=>this.seriesName(t.key)))):"right"===t&&this.stackConfig.by===Q.SCENARIOS&&n.push(...this.lastScenarios.map((t=>this.i18n.get(t)||t)))}this.hasPercentMark()&&this.percentMarkSide()===t&&n.push("100%");let r=0;for(const t of n)r=Math.max(r,wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width);return r}drawStackedHeaders(t,i){var s,e,n;if(!this.stackConfig||0===t.length)return;const r=this.stackConfig.by===Q.SCENARIOS,o=t.some((t=>null!=t.series));if(!r&&!o)return;const h=i.group().id("StackedHeaders"),a=this.position.getColumnPositionY(),l=this.position.getColumnWidth()/2,c=this.position.spacings.labelToColumn,u=t.map(((t,i)=>this.stackGroups(t).length>0?i:-1)).filter((t=>t>=0)),d=o&&null!==(s=u[0])&&void 0!==s?s:0,f=null!==(e=u[u.length-1])&&void 0!==e?e:t.length-1,v=i=>{const s="left"===i?d:f,e=this.stackGroups(t[s]);if(0===e.length)return;const n=this.position.getColumnCenterPositionX(s),r="left"===i?n-l-c:n+l+c,o=(t,s)=>{new Ta(h,r,t,"STACK_HEADER",s,this.styles,ka.Center,"left"===i?ka.Right:ka.Left).forceStringTypeDraw()};if(e.length>1)return void e.forEach(((t,i)=>{const{positive:s,negative:n,total:r}=t.layout;o(a-(i===e.length-1?(s-n)/2:r<0?0-n:s)*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[u]=e;u.segments.forEach(((t,i)=>{if(null!=t.label&&!Number.isFinite(t.value))return;const{start:s,end:e}=u.layout.segments[i];o(a-(s+e)/2*t.dataPoint.pixelPerUnit,null!=t.label?this.seriesName(t.label):this.i18n.get(t.scenario)||t.scenario)}))},p=null!==(n=this.stackConfig.legend)&&void 0!==n?n:"left";"left"!==p&&"both"!==p||v("left"),"right"!==p&&"both"!==p||v("right"),this.hasPercentMark()&&u.length>0&&this.drawPercentMark(h,"left"===this.percentMarkSide()?d:f)}drawPercentMark(t,i){const s=this.percentMarkSide(),e="left"===s?-1:1,n=this.position.getColumnPositionY()-dt*this.pixelPerUnit,r=this.position.getColumnCenterPositionX(i)+e*(this.position.getColumnWidth()/2),o=.45*this.styles.fontStyles.size,h=r+1*e,a=h+e*o;t.polygon([[h,n],[a,n-o/2],[a,n+o/2]]).fill(this.styles.fontStyles.color||"#000000").addClass("percent-mark"),new Ta(t,a,n-o/2,"STACK_PERCENT_MARK","100%",this.styles,ka.Bottom,"left"===s?ka.Right:ka.Left).forceStringTypeDraw()}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 e?r:["scenario1"])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===tt.RELATIVE?dt:0,u=t.map((t=>sc(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?Zs(this.ruleSet.getScenarioColorIndex(o[t])):null,h=new Lc(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 Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=Fc(t),s=i.length>0?i.reduce(((t,i)=>t+i),0)/i.length:NaN,e=Object.assign(Object.assign({},t[0]),{scenario1:new mc(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new mc(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 mc(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=Fc(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 mc(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new mc(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 mc(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=w.max(...s),n=w.min(...s),r=new ut;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 Fc(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 Gc{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=at.AUTO,this.axisLabelsMode=lt.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=ct.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.axisLabelsStep=1,this.scalingIndicator=0,this.totalColumn=null,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.locale="de"}}class jc{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=it.adaptArray(t.data,this.dataRowAdapter),s=it.adaptArray(t.scenarios,this.stringAdapter),e=new Gc(i,s);R.isArray(t.variances)&&(e.variances=it.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.isNumber(t.axisLabelsStep)&&t.axisLabelsStep>=1&&(e.axisLabelsStep=t.axisLabelsStep),R.isNumber(t.scalingIndicator)&&t.scalingIndicator>0&&(e.scalingIndicator=t.scalingIndicator);const n=t.totalColumn;return null!=n&&R.isNumber(n.pixelPerUnit)&&n.pixelPerUnit>0&&(e.totalColumn={pixelPerUnit:n.pixelPerUnit,label:"string"==typeof n.label?n.label:"",width:R.isNumber(n.width)&&n.width>0?n.width:1}),R.isBoolean(t.scenarioSwitch)&&(e.scenarioSwitch=t.scenarioSwitch),R.isString(t.axisTitlePosition)&&(e.axisTitlePosition=t.axisTitlePosition),R.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Gc([],[])}}const Ic=class{disconnectedCallback(){var t;this.overlapErrId&&(null===(t=this.errors)||void 0===t||t.remove(this.overlapErrId),this.overlapErrId=void 0)}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=at.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=lt.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=ct.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.axisLabelsStep=1,this.scalingIndicator=0,this.totalColumn=null,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.parentDimensions={width:0,height:0},l(this)}getDb(){return this.stores||(this.stores=u(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,s,e,n,r,o,h,a,l,c;if(this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),wi(this.errors,this.queryError),this.variances.every((t=>""===t))){const t=null!==(e=null===(s=this.chart)||void 0===s?void 0:s.getIgnoredSwitchScenarios())&&void 0!==e?e:[];t.length>0?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_stack_switch_ignored",type:"warning",message:`stack by dimensions with scenarioSwitch: ${t.join(", ")} is not drawn. A scenario continues the first one only where the first one has no value, and only in bar mode.`}):null===(r=this.errors)||void 0===r||r.remove("WARN_stack_switch_ignored")}const u=`WARN_variances_overlap_${this.variances.join("_")}`,d=null!==(h=null===(o=this.chart)||void 0===o?void 0:o.getVarianceOverlaps())&&void 0!==h?h:0;this.overlapErrId&&this.overlapErrId!==u&&(null===(a=this.errors)||void 0===a||a.remove(this.overlapErrId)),this.overlapErrId=d>0?u:void 0,d>0?null===(l=this.errors)||void 0===l||l.addOrReplace({id:u,type:"warning",message:`scenarioSwitch: the variances ${this.variances.join(", ")} share a row, but ${d} period(s) have more than one value. The first variance wins there.`}):null===(c=this.errors)||void 0===c||c.remove(u)}async componentWillLoad(){var t,i;const s=this.prepareConfig(),e=this.prepareStyle(),n=this.containerWidth||0;this.chart=new Uc(new se(this.ruleSetConfig),this.getDb(),this.tableName,s,e,n),this.chart.setI18n(this.i18n);const r=s.pixelPerUnit<=0,o=s.pixelPerPercentage<=0;this.autoFitScaling(s,e),this.chart.setAvailableHeight(r?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),o||this.chart.fitRelativeVariances((null===(i=this.parentDimensions)||void 0===i?void 0:i.height)||0),this.pattern=new pc(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t,i;if(null==this.chart)return;const s=this.prepareConfig(),e=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(e),this.chart.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new se(this.ruleSetConfig)),this.chart.setConfig(s);const n=s.pixelPerUnit<=0,r=s.pixelPerPercentage<=0;this.autoFitScaling(s,e),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),r||this.chart.fitRelativeVariances((null===(i=this.parentDimensions)||void 0===i?void 0:i.height)||0),this.pattern=new pc(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 Uc(new se(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(Ql,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=ic({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(Ql,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Ql,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=M(e,this.tableName,this.filter);return this.measureScaleError=void 0,new jc(new yc,new Tl,new hc,e,n,(t=>{this.measureScaleError=yi(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,axisLabelsStep:this.axisLabelsStep,scalingIndicator:this.scalingIndicator,totalColumn:this.totalColumn,scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.axisTitlePosition,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 xc(new uc,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};Ic.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 Bc=class{constructor(i){t(this,i),this.name="_default",l(this),this.errors=c(this),hi(this,(t=>{this.stores||(this.stores=u(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("ERR_body");const s=k(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)}};Bc.style="bn-component-style{display:none}";const Yc={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"]},Hc=Object.keys(Yc),Vc=["landscape","portrait"];function Xc(t,i){const s=null!=t&&Hc.includes(t),[e,n,r]=Yc[s?t:"xga"],o=e>=n?"landscape":"portrait",h=s&&Vc.includes(null!=i?i:"")?i:o,[a,l]=h===o?[e,n]:[n,e];return{width:`${a}${r}`,height:`${l}${r}`,orientation:h}}function Jc(t,i,s){const e=Xc(t,i),n=Vc.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 qc(t,i,s){const{width:e,height:n}=Jc(t,i,s);return`@page { size: ${e} ${n}; }`}const Kc=new Map,Qc={"thin-space":" ",space:" ",none:""};function Zc(t){var i;let s="";for(const t of Kc.values())s=t.separator()||s;const e=s?null!==(i=Qc[s])&&void 0!==i?i:s:null;if(e!==Oa.groupSeparator){Oa.groupSeparator=e;for(const[i,s]of Kc)i!==t&&s.redraw()}}const tu=["format","orientation","page-format","page-orientation","render-orientation","page-number"],iu=(t,i,s)=>{const e=t[i];return"string"==typeof e?e:i in t?null:t.getAttribute(s)},su=class{constructor(i){t(this,i),this.bnNotationChange=o(this,"bnNotationChange",7),this.groupSeparator="",this.wasConnected=!1,this.assignedPageNumbers=new WeakMap,this.notationSubscriptions=[],l(this),this.errors=c(this)}watchGroupSeparator(){Zc()}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=O(this.element),this.locale&&(this.stores.context.state.locale=this.locale),Kc.set(this,{separator:()=>{var t;return null!==(t=this.groupSeparator)&&void 0!==t?t:""},redraw:()=>{const t=this.stores.context.state,i=t.locale;t.locale="",t.locale=i}}),Zc(this.wasConnected?void 0:this),this.wasConnected=!0;const t=()=>this.bnNotationChange.emit();this.notationSubscriptions=[this.stores.scalingGroups.on("set",t),this.stores.componentStyles.on("set",t)],this.syncPages(),this.pageObserver=new MutationObserver((()=>this.syncPages())),this.pageObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:tu})}disconnectedCallback(){var t,i;Kc.delete(this),Zc(),this.notationSubscriptions.forEach((t=>t())),this.notationSubscriptions=[],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=iu(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?qc(iu(t,"pageFormat","page-format"),iu(t,"pageOrientation","page-orientation"),i):qc(iu(t,"format","format"),iu(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}):is(t,s)}catch(i){let e;try{e=is(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:bi,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=fi(n.map((t=>({tag:t.localName,explicitId:vi(t)}))));return h.forEach(((t,i)=>{t.id=a[i]})),{version:bi,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:pi(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:h}}async getNotation(t){const i=Array.from(this.element.querySelectorAll("bn-component-style, bn-scaling-group"));return await Promise.all(i.map((t=>{var i,s;return null!==(s=null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t))&&void 0!==s?s:Promise.resolve()}))),Mi(ft(this.stores.componentStyles.state,t),this.stores.scalingGroups.state)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"835bf8fe0cf78440c000ce996495c5c5c0cbbd07"},i("slot",{key:"395cbc8fdbb4f6e765d36a93a7547272e5ec7def"}))}get element(){return e(this)}static get watchers(){return{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}}};su.style=":host{display:block}";const eu=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],nu=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function ru(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function ou(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var hu=Uint8Array,au=Uint16Array,lu=Int32Array,cu=new hu([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]),uu=new hu([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]),du=new hu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fu=function(t,i){for(var s=new au(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new lu(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}},vu=fu(cu,2),pu=vu.b,gu=vu.r;pu[28]=258,gu[258]=28;for(var mu=fu(uu,0).b,bu=new au(32768),yu=0;yu<32768;++yu){var wu=(43690&yu)>>1|(21845&yu)<<1;bu[yu]=((65280&(wu=(61680&(wu=(52428&wu)>>2|(13107&wu)<<2))>>4|(3855&wu)<<4))>>8|(255&wu)<<8)>>1}var xu=function(t,i,s){for(var e=t.length,n=0,r=new au(i);n<e;++n)t[n]&&++r[t[n]-1];var o,h=new au(i);for(n=1;n<i;++n)h[n]=h[n-1]+r[n-1]<<1;if(s){o=new au(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[bu[u]>>a]=l}else for(o=new au(e),n=0;n<e;++n)t[n]&&(o[n]=bu[h[t[n]-1]++]>>15-t[n]);return o},Su=new hu(288);for(yu=0;yu<144;++yu)Su[yu]=8;for(yu=144;yu<256;++yu)Su[yu]=9;for(yu=256;yu<280;++yu)Su[yu]=7;for(yu=280;yu<288;++yu)Su[yu]=8;var $u=new hu(32);for(yu=0;yu<32;++yu)$u[yu]=5;var Mu=xu(Su,9,1),_u=xu($u,5,1),ku=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},Ou=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},Nu=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},Au=["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||Au[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,Ru),!s)throw e;return e},Lu=new hu(0);function Tu(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 hu(0);var r=!s,o=r||2!=i.i;r&&(s=new hu(3*n));var h,a,l=function(t){var i=s.length;if(t>i){var e=new hu(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=Ou(t,u,1);var b=Ou(t,u+1,3);if(u+=3,!b){var y=t[(R=4+((u+7)/8|0))-4]|t[R-3]<<8,w=R+y;if(w>n){Ru(0);break}o&&l(d+y),s.set(t.subarray(R,w),d),i.b=d+=y,i.p=u=8*w,i.f=c;continue}if(1==b)f=Mu,v=_u,p=9,g=5;else if(2==b){var x=Ou(t,u,31)+257,S=Ou(t,u+10,15)+4,$=x+Ou(t,u+5,31)+1;u+=14;for(var M=new hu($),_=new hu(19),k=0;k<S;++k)_[du[k]]=Ou(t,u+3*k,7);u+=3*S;var O=ku(_),N=(1<<O)-1,A=xu(_,O,1);for(k=0;k<$;){var R,L=A[Ou(t,u,N)];if(u+=15&L,(R=L>>4)<16)M[k++]=R;else{var T=0,E=0;for(16==R?(E=3+Ou(t,u,3),u+=2,T=M[k-1]):17==R?(E=3+Ou(t,u,7),u+=3):18==R&&(E=11+Ou(t,u,127),u+=7);E--;)M[k++]=T}}var C=M.subarray(0,x),P=M.subarray(x);p=ku(C),g=ku(P),f=xu(C,p,1),v=xu(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=(T=f[Nu(t,u)&W])>>4;if((u+=15&T)>m){Ru(0);break}if(T||Ru(2),U<256)s[d++]=U;else{if(256==U){z=u,f=null;break}var F=U-254;U>264&&(F=Ou(t,u,(1<<(I=cu[k=U-257]))-1)+pu[k],u+=I);var G=v[Nu(t,u)&D],j=G>>4;if(G||Ru(3),u+=15&G,P=mu[j],j>3){var I=uu[j];P+=Nu(t,u)&(1<<I)-1,u+=I}if(u>m){Ru(0);break}o&&l(d+131072);var B=d+F;if(d<P){var Y=0-P,H=Math.min(P,B);for(Y+d<0&&Ru(3);d<H;++d)s[d]=e[Y+d]}for(;d<B;++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 hu(h.subarray(0,a))):s.subarray(0,d)}(t.subarray(n,-8),{i:2},new hu(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var Eu="undefined"!=typeof TextDecoder&&new TextDecoder;try{Eu.decode(Lu,{stream:!0})}catch(t){}function Cu(t){return vt(t)}function Pu(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=Tu(r);return{hash:s,json:(new TextDecoder).decode(o)}}const Wu=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=l(this),this.errors=c(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=u(i),r=(i.getAttribute("datasources")||"").split(","),h(),a.observe(i,{attributes:!0,attributeFilter:["datasources"]}),f(l,t)};const c=t.disconnectedCallback;t.disconnectedCallback=()=>{a.disconnect(),n.forEach((t=>t())),n=[],v(e(t)),f(c,t)}})(this,(()=>{this.executeQuery()})),hi(this,(t=>this.sync(t)))}sync(t){if(this.stores=u(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=Pu(t);i=e.hash,s=e.json}catch(t){return this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${yi(t)}`}),void(this.lastBodyHash=null)}else i=Cu(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=u(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: ${yi(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(p(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 nu)i[t]=new Set;const s={};for(const t of eu)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 nu){const s=h[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of eu){const i=h[t];if(ru(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=eu.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=ou(i.rowGroup),c=ou(i.category),u=ou(i.subCategory),d=ou(i.columnGroup),f=ou(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=u(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: ${yi(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}]}}};Wu.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=l(this),this.errors=c(this),hi(this,(t=>this.sync(t)))}sync(t){var i;if(this.stores=u(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=Cu(t),e=t;else{const i=Pu(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: ${yi(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),v(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=u(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: ${yi(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 zu=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,l(this),this.errors=c(this),this.componentStyle=N(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)}};zu.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 Uu=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"']]),Fu="custom-template",Gu=/"[\w\d\s.]+"|'[\w\d\s.]+'/g,ju=/"[^"]*"|'[^']*'/g;function Iu(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 Bu(t,i){var s;return t===Fu?Iu(i).length>0?i:'"a"':null!==(s=Uu.get(t))&&void 0!==s?s:'"a"'}function Yu(t){var i;const s=(null===(i=Iu(t)[0])||void 0===i?void 0:i.length)||1;return Array(s).fill("minmax(0, 1fr)").join(" ")}function Hu(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 Vu(t){var i;const s=Iu(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(ju))&&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 Xu=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.cardOverlayArea="",this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,l(this),this.errors=c(this),this.componentStyle=N(this),this.resolveInherited=ri(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=u(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 Yu(this.getTemplatePattern(t))}getRowCount(t){return Iu(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(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))),this.overlayArea()?i("div",{style:{display:"flex",overflow:"hidden","grid-area":this.overlayArea(),"z-index":"1"}},i("slot",{name:"card-slot-"+s.length})):null)}overlayArea(){var t,i;const s=(null!==(t=this.cardOverlayArea)&&void 0!==t?t:"").trim();if(!/^\d+(\s*\/\s*\d+){3}$/.test(s))return;const[e,n,r,o]=s.split("/").map((t=>Number(t.trim()))),h=this.getRowCount(this.cardLayout),a=(null===(i=Iu(this.getTemplatePattern(this.cardLayout))[0])||void 0===i?void 0:i.length)||1;return e>=1&&n>=1&&r<=h+1&&o<=a+1&&e<r&&n<o?s:void 0}extractSlotNames(t){return Hu(t)}getTemplatePattern(t){return Bu(t,this.cardCustomTemplate)}componentWillRender(){var t;const i=this.cardLayout===Fu?Vu(this.cardCustomTemplate):void 0;i?this.errors.addOrReplace({id:"WARN_cardCustomTemplate",type:"warning",message:`cardCustomTemplate: ${i}`}):this.errors.remove("WARN_cardCustomTemplate"),""===(null!==(t=this.cardOverlayArea)&&void 0!==t?t:"").trim()||this.overlayArea()?this.errors.remove("WARN_cardOverlayArea"):this.errors.addOrReplace({id:"WARN_cardOverlayArea",type:"warning",message:`cardOverlayArea: '${this.cardOverlayArea}' is not 'row-start / column-start / row-end / column-end' in line numbers of the layout.`})}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:"ef0b6da39a573f162c096c21803e4d647b2817c2",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"9116df8c88198ebc922dc91d5f45a032a81d37d1",class:"cardtitle"},i("bn-title",{key:"6d9645d5229c3bf32ef944c1f296a55dbe4b3bee","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.titleProp("ruleset"),"title-font-size":this.componentStyle((t=>{var i;return null===(i=null==t?void 0:t["bn-layout-card"])||void 0===i?void 0:i.titleFontSize})),"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:"65803497adad305f02874acf441867e9ba200945"},i("div",{key:"61a57b87b0ffb76c238b2e2facb7d5b855d5dc10",style:s,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(e))),i("bn-footer",{key:"8589da921d0f8dac8e9a2af23315ded3a3ee3d51",text:this.footerText,"page-number":"0","display-page-number":"false"}))}get element(){return e(this)}};Xu.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 Ju=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,l(this),this.errors=c(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 Iu(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(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){return Hu(t)}getTemplateAreas(t){return Bu(t,this.pageCustomTemplate)}getGridTemplateColumns(t){return(i=t)===Fu||Uu.has(i)?Yu(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===Fu?Vu(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=Jc(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)}};Ju.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 qu=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){this.stores=u(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:Vt(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)}};qu.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 Ku=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(this)}validateFormat(t){const i="WARN_format";L(t)||Hc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${Hc.join(", ")}`})}validateOrientation(t){const i="WARN_orientation";L(t)||Vc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${Vc.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(Hc.includes(this.format)){const{width:i,height:s}=Xc(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}]}}};Ku.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 Qu=class{constructor(i){t(this,i),l(this),this.errors=c(this)}connectedCallback(){this.stores=u(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=oi(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=oi(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 (${ni(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}]}}};Qu.style="bn-scaling-group{display:none}";const Zu="none",td="setname";function id(t){return t===td?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function sd(t){if("string"==typeof t?""===t.trim():"number"!=typeof t)return;const i=Number(t);return Number.isFinite(i)?i:void 0}function ed(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=nd(t);return i?i.toISO():String(t)}function nd(t){if(null!=t){if("string"==typeof t){const i=w.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=w.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const rd=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.runningSum=!1,this.varianceWaterfall=!1,this.type="list",this.limit=0,this.thereof="[]",this.thereofPosition="below",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 ≈ ${ni(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 ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),this.errors=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),Zt(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 L(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!==sd(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&L(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=ti(this).t,this.resolveInherited=ri(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";p(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(qt(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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(L(t))return void this.errors.remove(i);const s=pt(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";gt(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"===ei(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"===ei(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";mt(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";bt(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";T(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=yt(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)}validateThereofPosition(t){const i="WARN_thereofPosition";L(t)||wt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"thereofPosition: invalid value '"+t+"' is not supported."})}validatePartOf(t){const i="WARN_partof",s=xt(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(qt(t))return void this.errors.remove(i);const s=St(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";qt(t)||G(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";$t(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";q(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";T(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";T(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";Mt(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=_t(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();L(t)||s===Zu||s===td||ot(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";L(t)||T(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=kt(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.validateThereofPosition(this.thereofPosition),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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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(){Bs(this.element,"bn-table-renderer");const{mode:t}=ii(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}=Xt(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=Xt(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 _(this.errors,null);const{mode:r}=ii(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)`),_(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 Ot[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareThereofPosition(){var t;return(null===(t=this.thereofPosition)||void 0===t?void 0:t.toLowerCase())===Nt.ABOVE?Nt.ABOVE:Nt.BELOW}prepareTableType(){var t;return At[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=>Rt(t))),direction:I[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return Lt.META}prepareI18n(){const t=g,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(),...ie(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 L(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((L(u.value)||f)&&L(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||L(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 L(this.categoryWidth)?Tt.INF:Tt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return L(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 L(this.measureType)?Et.VOLUME:Et[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=L(this.interval)?Zu:this.interval.trim().toLowerCase();return r!==Zu&&r!==td&&!ot(r)||r===Zu?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),this.errors.remove(n),Zu):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),Zu):(this.errors.remove(i),r===td?(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),td):(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."}),Zu):(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?Ct(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=Wt[i];return s?Pt[s]:Pt[Wt.W10]}prepareBarColumns(){return L(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=ei(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=ei(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=ui(i),n={},r=t.querySelector("thead");if(r){const t=e.toLocal(r.getBoundingClientRect());n.y=es(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];if(u){const t=u.classList.contains("block-start")&&"function"==typeof getComputedStyle&&parseFloat(getComputedStyle(u).borderLeftWidth)||0;n.x=es(e.toLocal(u.getBoundingClientRect()).x+t)}return 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=di(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:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:[],metadata:{},diagnostics:ai(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=ei(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=ei(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}=ii(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:"2af1b7f31952cd0ba32e0a069ce143d3402b4a77",style:t},i("div",{key:"b78ad13abb48a43c1da0aec4727372a482c39701"},i("bn-table-renderer",{key:"ab0132a3b57953379f6d8f5f19a18f95a14cc326",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereof:this.prepareThereOf(),thereofPosition:this.prepareThereofPosition(),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}],thereofPosition:[{validateThereofPosition: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}]}}};rd.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 od=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class hd{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){return this.format(this.value,t,i)}roundsToZero(t,i){return"number"==typeof this.value&&!!this.type&&this.draw(t,i)===this.format(0,t,i)}format(t,i,s){let e=t;if("undefined"===e||void 0===e||null==e)return"";if(Number.isNaN(Number(e)))return e;if(""===this.type||void 0===this.type||null==this.type)return e;let n=i.percent,r=i.percent;return"percentpoint"===this.type?Oa.number(Number(e),"percent",n,r,1,s).replace(od,""):("decimal"===this.type&&(e=+e/this.measureScale,n=i.decimal,r=i.decimal),Oa.number(Number(e),this.type,n,r,1,s))}drawPrefix(){return null==this.prefix?"":this.prefix}}class ad{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Dt.HEADER:return"groupheader";case Dt.SEPERATORLINE:return"";case Dt.DRILLELEMENT:return"ofit";case Dt.PARTELEMENT:return"partof";case Dt.STANDARD:return"";case Dt.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;if("category"===i&&null!=h&&(f=`category-${h.toString()}`),this.type===Dt.HEADER?f="headerlabel":this.type===Dt.SEPERATORLINE&&(f=null!=r?r:i),this.type===Dt.PARTELEMENT){const s=new Xs(i);s.isValid&&Number.isFinite(t)?(e="d"===s.type?"percentpoint":"percent",f=(null!=r?r:"").replace(/^(pos|neg)_\w+/,"$1_neu")):(("percent"===e||s.isValid)&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",f=""))}("-"===t||t===et&&"percent"===e)&&(f="");let v="prefix-first";o&&(v="prefix-second"),s&&(f=`${f} ${s}`);const p=new hd(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 ld=.85,cd=.3,ud=.25;function dd(t){const i=.6*t;return{barY:(t-i)/2,barHeight:i}}const fd={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};let vd;function pd(t,i,s,e,n=!1){const r=()=>function(t,i){var s;let e=0;for(const i of t)e+=null!==(s=fd[i])&&void 0!==s?s:/[0-9+]/.test(i)?.59:.72;return e*i*1.1}(t,i)*(n?1.08:1),o=function(){var t,i,s;if(void 0===vd)try{vd="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){vd=null}return vd}();if(o){o.font="1px __bn_font_sentinel__";const h=o.font;if(o.font=`${e?"italic ":""}${n?"bold ":""}${i}px ${s}`,o.font===h)return r();const a=o.measureText(t).width;if(Number.isFinite(a)&&(a>0||""===t))return a+.15*i}return r()}function gd(t,i){return Math.max(0,(t-.5)*i)}function md(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 bd(t,i,s,e){const{sides:n,neg:r,pos:o}=md(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 yd(t,i,s,e){const n=gd(t,i),{sides:r,neg:o,pos:h}=md(s,e/2,cd*i);return o+h+r*function(t,i,s){return Math.min(1*i,t/(2*s))}(n,i,r)<=n+1e-6}function wd(t,i){const s=.15*t;return{maxBarWidth:t,breakGap:i,overdriveZoneWidth:s,cutWidth:Math.max(0,t-i-s)}}function xd(t,i,s,e){var n,r;const o=gd(t,i),h=cd*i,{extent:a,axisX:l}=bd(o,s,ud*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:wd(f,c),pos:wd(g,c),axisX:u?l-a+f:0,labelGap:h}}function Sd(t,i,s,e,n){var r,o;const h=gd(t,i),a=cd*i,{extent:l,axisX:c}=bd(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}}function $d(t,i,s){const e=gd(t,i),n=cd*i,r=Math.min(2.85*i,e/4);let o=r,h=r;const a=s?s.max-s.min:0;if(s&&a>0){const t=(t,i)=>Math.max(0,...s.labels.filter((i=>i.pointsLeft===t)).map((e=>e.width+n-(t?e.end-s.min:s.max-e.end)*i)));o=t(!0,0),h=t(!1,0);const i=e/2;for(let s=0;s<8;s++){const s=Math.max(0,e-o-h)/a,n=Math.min(o,t(!0,s)),r=Math.min(h,t(!1,s)),l=n+r<=i||n===o&&r===h;if(o=n,h=r,l)break}if(o+h>i)if(Math.min(o,h)>r){const t=i/(o+h);o*=t,h*=t}else o<=h?h=i-o:o=i-h}return{totalWidth:e,labelAreaLeft:o,labelAreaRight:h,barAreaWidth:e-o-h,labelGap:n}}const Md={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},_d="#666666";function kd(t,i){return`pattern-${t}-${i.replace("#","")}`}function Od(t,i){return kd(`head-${t}`,i)}const Nd=({styles:t})=>{const s=t.scaleFactor,e=3*s,n=[{id:kd("pos",t.positive.stroke),line:t.positive.stroke,background:"#ffffff",lineWidth:1},{id:kd("neg",t.negative.stroke),line:t.negative.stroke,background:"#ffffff",lineWidth:1},{id:kd("neu",t.neutral.stroke),line:t.neutral.stroke,background:"#ffffff",lineWidth:1},...["ac","pp","fc","pl"].flatMap((i=>[{id:kd(i,t.scenarios[i].stroke),line:t.scenarios[i].stroke,background:"#ffffff",lineWidth:1},{id:Od(i,t.scenarios[i].stroke),line:"#ffffff",background:t.scenarios[i].stroke,lineWidth:.6}]))],r=[[0,e,e,0],[-s,s,s,-s],[e-s,e+s,e+s,e-s]];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:t.background}),r.map((([e,n,r,o])=>i("line",{x1:e,y1:n,x2:r,y2:o,stroke:t.line,"stroke-width":t.lineWidth*s})))))))};function Ad(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?Oa.number(t,"percent",i,i,1,e):Oa.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=>Oa.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(Oa.number(a/c,"decimal",d,0,1,e),Oa.number(0,"decimal",d,0,1,e))+u}function Rd(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 Td(t,i){if(Rd(t))return null;const s=new Xs(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 Ed=({x:t,height:s,look:e,styles:n})=>{const r=n.scaleFactor,o=ud*n.emPx,{reference:h,referenceSlot:a}=e;let l;if("outlined"===h.fillpattern){const e=o/3,n=(o-e)/2;l=[t-n,t+n].map((t=>i("line",{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":e})))}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 Cd(t){return void 0!==t.pos||void 0===t.neg}function Pd(t,i){return{neg:t.min<0?i:void 0,pos:t.max>0?i:void 0}}function Wd(t,i,s,e){return Rd(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 Dd(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${kd(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function zd(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Ud=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,bold:v,styles:p=Md}=t,g=p.scaleFactor,m=p.fontSize,b=h||Ad(s,!1,a,l,0,!0,c),y=null!=d?d:Pd(n,pd(b,m,p.fontFamily,!1,v)),w=s>0||0===s&&Cd(y),{neg:x=Math.max(0,-n.min),pos:S=Math.max(0,n.max)}=null!=f?f:{},$=xd(u,p.emPx,y,{neg:x,pos:S}),{totalWidth:M,axisX:_,labelGap:k}=$,{breakGap:O,overdriveZoneWidth:N,cutWidth:A}=w?$.pos:$.neg,R=Math.abs(s)*p.unitScaling*m,L=R-A>1e-6,T=Math.max(0,(w?S:x)*p.unitScaling*m-A),E=Math.max(0,R-A),C=T>0?E/T*N:0,{barY:P,barHeight:W}=dd(r),D=Td(e,p),z=Wd(e,s,o,p),U=null==D?void 0:D.minuend.fillpattern,F="hatched"===U||"outlined"===U?Object.assign(Object.assign({},z),{fillpattern:U}):z,G=Dd(F,Rd(e)?Ld(e):o?w?"pos":"neg":w?"neg":"pos"),{stroke:j,strokeWidth:I}=D&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:zd(F),B=D?ud*p.emPx/2:0,Y=w?_+B:_-B,H=L?A:R,V=L?A+O+C:R,X=w?Y+V+k:Y-V-k,J=w?"start":"end";return i("svg",{width:M,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(Nd,{styles:p}),!D&&i("line",{x1:_,y1:0,x2:_,y2:r,stroke:_d,"stroke-width":1*g}),H>0&&i("rect",{x:w?Y:Y-H,y:P,width:H,height:W,fill:G,stroke:j,"stroke-width":I*g}),L&&C>0&&i("rect",{x:w?Y+A+O:Y-A-O-C,y:P,width:C,height:W,fill:G,stroke:j,"stroke-width":I*g}),L&&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})]}(w?Y+A:Y-A-O,O,P,W,g),D&&i(Ed,{x:_,height:r,look:D,styles:p}),i("text",{x:X,y:r/2,dy:"0.35em","text-anchor":J,fill:p.fontColor,"font-size":m,"font-family":p.fontFamily},b))},Fd=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,bold:m,styles:b=Md}=t,y=b.scaleFactor,w=b.fontSize,x=8*y,S=100*b.percentageScaling*w,$=l||Ad(n,!0,c,u,d,f),M=pd($,w,b.fontFamily,!0,m),_=null!=p?p:Pd(o,M),{neg:k=Math.max(0,-o.min),pos:O=Math.max(0,o.max)}=null!=g?g:{},{totalWidth:N,negPinLength:A,posPinLength:R,axisX:L,labelGap:T}=Sd(v,b.emPx,_,x,{neg:k*S,pos:O*S}),E=h/2,C=Math.abs(n)*S,P=n>0||0===n&&Cd(_),W=P?R:A,D=C-W>1e-6,z=P?1:-1,U=L+z*Math.min(C,W),F=Wd(r,n,a,b),G=Td(r,b),j=null!==(s=null==G?void 0:G.minuend)&&void 0!==s?s:b.scenarios.ac,I=L+z*(W+x/2),B=1.2*x,Y=I-z*B,H=.2*w,V=M+2*H,X=Math.abs(Y-L)-ud*b.emPx/2,J=D&&X>=V+2*H,q=Y-z*(H+V/2)-V/2,K=J?q+V/2:(D?I:U+z*(x/2))+z*T;return i("svg",{width:N,height:h,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i(Nd,{styles:b}),D?i("polygon",{points:`${I},${E} ${Y},${E-B/2} ${Y},${E+B/2}`,fill:F.fill}):i("rect",{x:U-x/2,y:E-x/2,width:x,height:x,fill:"outlined"===j.fillpattern?"#ffffff":"hatched"===j.fillpattern?`url(#${Od(null!==(e=null==G?void 0:G.minuendSlot)&&void 0!==e?e:"ac",j.stroke)})`:j.fill,stroke:j.stroke,"stroke-width":1*y}),i("line",{x1:L,y1:E,x2:D?Y:U,y2:E,stroke:F.fill,"stroke-width":3*y}),J&&i("rect",{class:"pin-label-band",x:q,y:E-3*y/2,width:V,height:3*y,fill:"#ffffff","fill-opacity":"0.5"}),G?i(Ed,{x:L,height:h,look:G,styles:b}):i("line",{x1:L,y1:0,x2:L,y2:h,stroke:_d,"stroke-width":1*y}),i("text",{x:K,y:h/2,dy:"0.35em","text-anchor":J?"middle":P?"start":"end",fill:b.fontColor,"font-size":w,"font-style":"italic","font-family":b.fontFamily},$))},Gd=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=Md}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?Fd:Ud,Object.assign({},t))};function jd(t,i,s,e,n,r=!1){const o=Ad(t,"partof"===i,s,e,0,!0,n);return r?o:o.replace(/^\+/,"")}const Id=t=>{var s;const{value:e,scenario:n,height:r,isPositiveGood:o,measureScale:h,locale:a,decimalDigits:l,columnWidthEm:c=10,styles:u=Md,waterfall:d,geometry:f,bold:v,connectorReach:p={top:0,bottom:0}}=t,g=u.scaleFactor,m=u.fontSize,b=d.max-d.min;if(null==e||isNaN(e)||b<=0)return i("span",{class:"bar-chart-empty",style:{color:u.fontColor,fontStyle:"italic"}},"-");const{totalWidth:y,labelAreaLeft:w,barAreaWidth:x,labelGap:S}=null!=f?f:$d(c,u.emPx),$=x/b,M=t=>w+(t-d.min)*$,{barY:_,barHeight:k}=dd(r),O=M(0),N=M(d.start),A=M(d.end),R=Math.min(N,A),L=Math.abs(A-N),T=Td(n,u),E=Wd(n,e,o,u),C=null==T?void 0:T.minuend.fillpattern,P="hatched"===C||"outlined"===C?Object.assign(Object.assign({},E),{fillpattern:C}):E,W=Dd(P,T?E===u.positive?"pos":"neg":Ld(n)),{stroke:D,strokeWidth:z}=T&&"hatched"===P.fillpattern?{stroke:P.stroke,strokeWidth:1}:zd(P),U=jd(e,d.kind,h,a,l,null!==T),F=A<N,G=F?R-S:R+L+S,j=F?"end":"start",I=pd(U,m,u.fontFamily,!1,v),B=S/2,Y=(F?G-I:G)-B,H=(F?G:G+I)+B,V=t=>t>Y&&t<H,X=void 0!==d.parentEnd?M(d.parentEnd):void 0,J=r/2-m/2,q=r/2+m/2,K=(t,i,s,e=0)=>t+e>Y&&t-e<H?[[i,Math.min(s,J)],[Math.max(i,q),s]].filter((([t,i])=>i>t)):[[i,s]],Q=-p.top,Z=r+p.bottom;return i("svg",{width:y,height:r,class:"cell-bar-chart waterfall-bar"+(T?" variance-waterfall":""),style:{overflow:"visible"}},i(Nd,{styles:u}),!T&&!V(O)&&i("line",{x1:O,y1:0,x2:O,y2:r,stroke:_d,"stroke-width":1*g}),void 0!==d.parentStart&&void 0!==d.parentEnd&&i("line",{x1:M(d.parentStart),y1:0,x2:M(d.parentStart),y2:r,stroke:_d,"stroke-width":1*g,"stroke-dasharray":`${2*g},${2*g}`}),void 0!==d.parentStart&&void 0!==X&&!V(X)&&i("line",{x1:X,y1:0,x2:X,y2:r,stroke:_d,"stroke-width":1*g,"stroke-dasharray":`${2*g},${2*g}`}),null===(s=d.connectors)||void 0===s?void 0:s.map((({at:t,part:s})=>K(M(t),"bottom"===s?_+k:Q,"top"===s?_:Z).map((([s,e])=>i("line",{class:"waterfall-connector",x1:M(t),y1:s,x2:M(t),y2:e,stroke:_d,"stroke-width":1*g}))))),L>0&&i("rect",{x:R,y:_,width:L,height:k,fill:W,stroke:D,"stroke-width":z*g}),T&&K(O,Q,Z,ud*u.emPx/2).map((([t,s])=>i("g",{transform:`translate(0,${t})`},i(Ed,{x:O,height:s-t,look:T,styles:u})))),i("text",{x:G,y:r/2,dy:"0.35em","text-anchor":j,fill:u.fontColor,"font-size":m,"font-family":u.fontFamily},U))},Bd=`IFNULL(${_a.ROWGROUP}, '')`;class Yd{constructor(t){this.groups=[_a.CATEGORY,_a.CATEGORYINDEX],At.OPT!==t.type&&At.OPTNOTOTAL!==t.type||this.groups.unshift(_a.OPERATION),t.grouped&&(this.groups.push(_a.ROWGROUP),this.groups.push(_a.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===_a.ROWGROUP?Bd:t)).toString()}select(){return this.groups.map((t=>t===_a.ROWGROUP?`${Bd} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==_a.CATEGORY))}toArray(){return this.groups}}function Hd(t,i){return Math.abs(t-i)<=1e-9*Math.max(1,Math.abs(t),Math.abs(i))}function Vd(t,i){const s=(t,i,s)=>{var e;t.connectors=[...null!==(e=t.connectors)&&void 0!==e?e:[],{at:i,part:s}]},e=(t,i,e,n)=>{s(t,n,"bottom"),i.forEach((t=>s(t,n,"through"))),s(e,n,"top")};let n=null;for(const s of t){if(null===s){n=null;continue}const{main:t,children:r}=s,o="anchor"===t.kind?t.end:t.start;if(n&&!s.gapAbove&&Hd(n.main.end,o)&&e(n.main,i?r:n.children,t,o),!s.gapAbove&&!s.gapBelow&&(r.forEach(((t,i)=>{i>0&&e(r[i-1],[],t,t.start)})),r.length>0)){const s=r[r.length-1];i?Hd(s.end,t.end)&&e(s,[],t,t.end):e(t,[],r[0],t.start)}n=s.gapBelow?null:s}}class Xd{constructor(){this.geometry=new Map,this.columns=new Set}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s),this.columns.add(i)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}has(t){return this.columns.has(t)}}function Jd(t){for(const i of t)for(const t of i){const i=t[_a.TYPE];if(i===Dt.SUM||i===Dt.GROUPSUM||i===Dt.DRILLELEMENT||i===Dt.PARTELEMENT)return!0}return!1}function qd(t){return`${t}__signed`}function Kd(t){var i;return"-"===(null!==(i=t[_a.OPERATION])&&void 0!==i?i:t.restOperation)?-1:1}function Qd(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);if(isNaN(n))return null;if((s===At.OPT||s===At.OPTNOTOTAL)&&t[_a.TYPE]===Dt.ENTRY){const s=t[qd(i)];return"number"==typeof s?s:Kd(t)*n}return n}function Zd(t,i){return null==t&&null==i?i:(null!=t?t:0)+(null!=i?i:0)}class tf{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(!zt.test(t))throw new Error(`invalid identifier "${t}"`);const e=[],n=[],r=[],o=this.scenariosSQL(!1),h=this.scenariosSQL(!0),a=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new Yd(this.config),u=this.config.interval===td?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var i,s;return null!==(s=null===(i=Ut(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===_a.ROWGROUP||t===_a.ROWGROUPINDEX||t.toUpperCase()in Ft)),g=p.filter((t=>t.toUpperCase()in Ft)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),m=p.length>0?p.map((t=>`${t} ${v}`)).toString():`${_a.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${_a.CATEGORY}) as ${_a.TOTALROWCOUNT} ${this.config.grouped?`, ${Bd} as ${_a.ROWGROUP}, FIRST(${_a.ROWGROUPINDEX}) as ${_a.ROWGROUPINDEX}${g}`:""}\n FROM ${i} ${this.config.grouped?`GROUP BY ${Bd} ORDER BY ${m}`:""}`);return 0===b.length||1===b.length&&0===(null!==(s=b[0][_a.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 (${_a.ROWGROUP} IS NULL OR ${_a.ROWGROUP} = '')`:`WHERE ${_a.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.hasRunningSum()&&this.accumulateGroupSums(r,[...new Set(this.exctractScenarioNames(h))]),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 Xs(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===At.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=[...new Set(this.exctractScenarioNames(t))],l=[];s.forEach((function(t){l.push(...o.exec(t,h))}));const c=new Map;l.forEach((t=>c.set(t[_a.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,a),r.forEach((t=>{this.toShares(t,c.get(t[_a.ROWGROUP]),a)})),this.injectDrillRowsToResultRows(r,e)}toShares(t,i,s){var e;const n=s=>t[s]/(i?i[s]:Number.NaN),r=new Map;for(const t of s){const i=new Xs(t);i.isValid&&r.set(t,n(i.base)-n(i.delta))}for(const i of s)t[i]=null!==(e=r.get(i))&&void 0!==e?e:n(i)}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=this.exctractScenarioNames(e).filter((t=>{var i;return null===(i=this.config.barColumns)||void 0===i?void 0:i.includes(t)})).map((t=>`, SUM(${t} * transformOperator(operation)) as ${qd(t)}`)).join(""),l=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type?`, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${a}`:"";i.push(`SELECT ${_a.ROWNR}, 1 as ${_a.ROWGROUPINDEX} , 'ENTRY' as ${_a.TYPE}, 'NO_GROUP' as ${_a.ROWGROUP}, ${this.bind(String(null!==(o=t.rowGroup)&&void 0!==o?o:""))} as restRowGroup, 'REST' as ${_a.CATEGORY}${l} ${h.length>0?", "+h:""} FROM (SELECT ROWNUM() AS ${_a.ROWNR}, ${i.length} as ${_a.ROWGROUPINDEX} , 'ENTRY' as ${_a.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${_a.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 ${_a.ROWNR},\n ${t.length} as ${_a.ROWGROUPINDEX},\n 'ENTRY' as ${_a.TYPE},\n ${this.bind(String(i.rowGroup||"NO_GROUP"))} as ${_a.ROWGROUP},\n '${_a.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 ${_a.ROWNR},\n ${i.length} as ${_a.ROWGROUPINDEX},\n 'GROUPHEAD' as ${_a.TYPE},\n ${s} as ${_a.ROWGROUP} ${this.config.showGroupTitle?`,${e} as ${_a.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return At.SUM===this.config.type||At.SUMNOTOTAL===this.config.type||At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type}hasRunningSum(){return this.config.runningSum&&this.config.grouped&&this.hasGroupSum()&&0===this.config.categoryThereOf.size}accumulateGroupSums(t,i){const s={};for(const e of t)for(const t of e)if("GROUP_SUM"===t[_a.TYPE])for(const e of i)s[e]=Zd(s[e],t[e]),t[e]=s[e]}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 ${_a.ROWGROUPINDEX},\n '=' as ${_a.OPERATION},\n ${o} as ${_a.ROWGROUP},\n ROWNUM() AS ${_a.ROWNR},\n 'GROUP_SUM' as ${_a.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `),i.push(`SELECT ${t.length} as ${_a.ROWGROUPINDEX},\n '=' as ${_a.OPERATION},\n ${o} as ${_a.ROWGROUP},\n ROWNUM() AS ${_a.ROWNR},\n 'GROUP_SUM' as ${_a.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `)}}createTotalSumRow(t,i,s){var e;if(At.SUM===this.config.type||At.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 ${_a.ROWGROUPINDEX},\n ${this.bind(n)} as ${_a.ROWGROUP},\n '=' as ${_a.OPERATION},\n 'SUM' as ${_a.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${_a.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${_a.ROWGROUP},\n '=' as ${_a.OPERATION},\n 'SUM' as ${_a.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[_a.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[_a.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[_a.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+=` ${_a.CATEGORY} = ${this.bind(e.category)}`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(o+=` ${r?"":"AND"} ${_a.ROWGROUP} = ${this.bind(e.rowGroup)}`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(o+=` ${r?"":"AND"} ${_a.SUBCATEGORY} = ${this.bind(e.subCategory)}`),o+=")",n.push(`SELECT ROWNUM() AS ${_a.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${_a.TYPE},\n ${_a.CATEGORY},\n ${_a.SUBCATEGORY},\n ${this.drillRowGroup} as ${_a.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.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[_a.TYPE]&&i.forEach(((i,s)=>{var e;t[s]=null!==(e=nt(t[s],t[i]))&&void 0!==e?e:et}))}))}))}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[_a.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===Zu||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const o="##",h=`(SELECT *, ${id(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.scenariosSQL(!1),l=this.scenariosSQL(!0),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new Yd(this.config),f=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(At.SUM===this.config.type||At.SUMNOTOTAL===this.config.type||At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type),p=this.checkConfigForPartOf()&&this.config.type!==At.LIST,g=t=>this.exec(t),m=t=>(this.config.scenarios.forEach((i=>{const s=new Xs(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=nt(t[s],t[i]))&&void 0!==e?e:et})),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=ed(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=ed(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 ${Bd} as ${_a.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY ${Bd}, __interval`):[],S=new Map;if(x.forEach((t=>S.set(`${t.rowGroup}${o}${ed(t.__interval)}`,t))),v&&this.hasRunningSum()){const i=[...new Set(this.exctractScenarioNames(l))],s=t.flat().filter((t=>"GROUP_SUM"===t.type));for(const t of new Set(x.map((t=>ed(t.__interval))))){let e;for(const n of s){const s=S.get(`${n.rowGroup}${o}${t}`);if(s){null!=e||(e={});for(const t of i)e[t]=Zd(e[t],s[t])}e&&b(n,m(Object.assign({},e)),t)}}}else if(v)for(const i of x){const s=ed(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 $=At.SUM===this.config.type||At.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(ed(t.__interval),t))),$)for(const i of M){const s=ed(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 ${_a.ROWGROUP}, ${_a.CATEGORY}, ${_a.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.SUBCATEGORY}, __interval`))}));for(const s of i){const i=ed(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 (${_a.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`),i+=")"}));const s=g(`SELECT ${_a.CATEGORY}, ${this.config.grouped?`${_a.ROWGROUP}`:`'SUM_TOTAL' as ${_a.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${i}\n GROUP BY ${_a.ROWGROUP}, ${_a.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${o}${t.category}${o}${ed(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=ed(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${o}${s}`):_.get(s);this.toShares(i,e,c),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+=` ${_a.CATEGORY} = ${this.bind(t.category)}`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${_a.SUBCATEGORY} = ${this.bind(t.subCategory)}`),s+")"}scenariosSQL(t){const i=this.config.scenarios,s=i.map((i=>this.translateScenarioSQL(i,t,this.config.type)));if(this.checkConfigForPartOf()&&this.config.type!==At.LIST){const e=new Set;for(const t of i){const i=new Xs(t);i.isValid&&e.add(i.base).add(i.delta)}for(const n of e)i.includes(n)||s.push(this.translateScenarioSQL(n,t,this.config.type).split(", COUNT(")[0])}return s.toString()}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 Xs(t);if(At.OPT===s||At.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!==At.OPT&&this.config.type!==At.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?Bd:_a.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=Gt.ASC===t.direction?Gt.DESC:Gt.ASC,s=new Map;t.hierarchy.forEach(((t,i)=>{const e=Ut(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=Ut(t))||void 0===i?void 0:i.kind;return"scenario"===s||"variance"===s}));e&&(this.sortSelect+=`, CASE WHEN ${_a.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=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",n=void 0===i?"":`TRIM(CAST(${id(td)} 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 Xs(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 ${_a.ROWGROUP}`,o="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${_a.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${_a.ROWGROUP} `,o="1"),n+=")"})),e.push(`SELECT ${o} AS ${_a.ROWNR},\n 'PARTELEMENT' as ${_a.TYPE},\n ${_a.CATEGORY},\n ${r},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.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 sf{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)?Zs(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 ad(l?1:0,0,Dt.HEADER),u=new ad(l?2:1,0,Dt.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);c.createElement(i?s.get(i.label)||i.label:Oa.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 ad(0,0,Dt.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=Oa.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=Oa.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s,e=0){let n=[{name:_a.CATEGORY,group:_a.CATEGORY,type:_a.CATEGORY,order:void 0}];At.OPT!==t&&At.OPTNOTOTAL!==t||(n=[{name:_a.OPERATION,group:_a.OPERATION,type:_a.OPERATION,order:void 0},{name:_a.CATEGORY,group:_a.CATEGORY,type:_a.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 tf(t,i);var a;this.dateBuckets=(a=t.interval)!==Zu&&a!==td,this.unsignedEntries=At.OPT===t.type||At.OPTNOTOTAL===t.type;const l=h.execute(s,e);this.hasBlankRowGroup=h.hasBlankRowGroup;const c=this.calculateColumnStatistics(l,t.barColumns,t.interval!==Zu),u=t.thereOfPosition===Nt.ABOVE,d=null!==(n=t.barColumns)&&void 0!==n?n:[],f=d.filter((t=>t.toUpperCase().trim()in Ft)),v=[...f.length>0&&Jd(l)?f:[],...t.varianceWaterfall?d.filter((t=>"d"===new Xs(t).type)):[]],p=v.length>0&&t.interval===Zu&&0===t.categoryThereOf.size?function(t,i,s,e=!1,n=!1){const r=new Xd,o=s===At.OPT||s===At.OPTNOTOTAL;for(const h of i){const i=new Xs(h).isValid;let a,l=0,c=0;const u=[],d=[];let f=null;const v=(t,i)=>(u.push(i),r.set(t,h,i),i),p=t=>{f=t&&{main:t,children:[],gapAbove:!1,gapBelow:!1},d.push(f)};for(const r of t)for(const t of r){const r=t[_a.TYPE];if(r===Dt.GROUPHEAD){e||(l=0),a=void 0,p(null);continue}const u=Qd(t,h,s);if(r===Dt.ENTRY){if(null===u){a=void 0,p(null);continue}p(v(t,{start:l,end:l+u,min:0,max:0,kind:"cascade"})),a={start:l,end:l+u,sign:o?Kd(t):1},c=a.start,l+=u}else if(r===Dt.SUM||r===Dt.GROUPSUM){if(null===u){a=void 0,p(null);continue}p(v(t,{start:0,end:u,min:0,max:0,kind:"anchor"})),a={start:0,end:u,sign:1},c=0,l=r!==Dt.GROUPSUM||e?u:0}else if(!i||r!==Dt.DRILLELEMENT&&r!==Dt.PARTELEMENT){if(r===Dt.DRILLELEMENT){if(null===u||void 0===a)continue;const i=c+(Math.sign(a.end-a.start)||1)*Math.abs(u);v(t,{start:c,end:i,min:0,max:0,kind:"thereof",parentStart:a.start,parentEnd:a.end}),c=i}else if(r===Dt.PARTELEMENT){if(null===u||void 0===a)continue;const i=c+u*(a.end-a.start);v(t,{start:c,end:i,min:0,max:0,kind:"partof",parentStart:a.start,parentEnd:a.end}),c=i}}else if(r===Dt.DRILLELEMENT&&null!==u&&void 0!==a&&f){const i=c+a.sign*u;f.children.push(v(t,{start:c,end:i,min:0,max:0,kind:"thereof"})),c=i}else f&&(n&&r===Dt.DRILLELEMENT?f.gapAbove=!0:f.gapBelow=!0)}i&&Vd(d,n);let g=0,m=0;for(const t of u)g=Math.min(g,t.start,t.end),m=Math.max(m,t.start,t.end);for(const t of u)t.min=g,t.max=m}return r}(l,v,t.type,h.hasRunningSum(),u):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,p,u));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[_a.TYPE];if(r!==Dt.SUM&&r!==Dt.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,u=!1){var d,f,v;const p=[];let g,m,b=-1;for(const y of e){const w=y[_a.ROWGROUP],x=""===w?"-":w,S=y[_a.SUBCATEGORY],$=y[_a.TYPE],M=y[_a.ROWNR]>=2;m=null!==(f=null!==(d=y.operation)&&void 0!==d?d:y.restOperation)&&void 0!==f?f:m;const _=u&&$===Dt.DRILLELEMENT&&void 0!==g&&g[_a.CATEGORY]===y[_a.CATEGORY]&&("NO_GROUP"===g[_a.ROWGROUP]||g[_a.ROWGROUP]===w),k=this.createDetailRow($,r+=1,n,e.length);k.key=this.rowKey(y);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(y,e),r=null!==(v=null==a?void 0:a.includes(e.type))&&void 0!==v&&v,u=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(y,e.type):void 0,d=$===Dt.PARTELEMENT&&new Xs(e.type).isValid,f=r&&!d,p=f?null==l?void 0:l.get(e.type):void 0;k.createElement(d&&s===Ot.PERCENT?"-":this.translateSumCellLabel(t,i,n,x,S,$,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),_?null:this.translateCellPrefix(i,$,e.type),this.translateScenarioCSS(e.type,n,m),M,o,null==h?void 0:h.value,f,p,1,u);const g=k.elements[k.elements.length-1];this.dateBuckets&&void 0!==e.bucket&&(g.date=cs(e.bucket));const b=new Xs(e.type);b.isValid&&(g.direction=this.resolveDirection(b,m))}_?(k.cssStyle="ofit-above",p[b].cssStyle="ofit-sum",p.splice(b,0,k),b+=1):($===Dt.ENTRY&&(b=p.length,g=y),p.push(k))}return p}rowKey(t){var i;const s=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case Dt.ENTRY:return{rowGroup:s,category:t.category,subCategory:t.subCategory};case Dt.DRILLELEMENT:return{rowGroup:s,category:t.category,subCategory:null!==(i=t.rawSubCategory)&&void 0!==i?i:t.subCategory};case Dt.GROUPSUM:return{rowGroup:s,row:"subtotal"};case Dt.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 Dt.GROUPHEAD:return new ad(i,s,Dt.HEADER);case Dt.SUM:case Dt.GROUPSUM:return new ad(e+2,s,Dt.SUM);case Dt.DRILLELEMENT:return new ad(e+2,s,Dt.DRILLELEMENT);case Dt.PARTELEMENT:return new ad(e+2,s,Dt.PARTELEMENT);default:return new ad(i,s,Dt.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===Lt.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,o)?t===Lt.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,o)?t===Lt.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,o)?t===Lt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,o)?t===Lt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s||s===et?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 Xs(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 Js(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 Xs(t);return i===Ot.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 ef{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new se,this.db=i,this.dataSetFactory=new sf(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=jt.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=jt.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=jt.DIRTY,this.fromExpr=M(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=jt.UP_TO_DATE}getHeader(){return this.state===jt.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===jt.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===jt.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===Zu||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=Zu:(this.config.interval=function(t,i,s){var e;if(s!==at.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=nd(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?at.DAY:(new ut).calculateDistanceType(w.fromMillis(r),w.fromMillis(o))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){if(s===td){const e=t.exec(`SELECT ${id(s)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${i}`),n=new Set,r=new Map,o=[];for(const t of e){const i=ed(t.__interval);n.has(i)||(n.add(i),o.push({key:i,label:0===i.length?"-":i}));const s=sd(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 ${id(s)} as __interval FROM ${i}`),r=new Set,o=[];for(const t of n){const i=nd(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 ut;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=Zu))}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=>Ut(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),h=this.config.interval===td?null==o?void 0:o.bucket:void 0,a=(t,i)=>{var e;return null==o||(null===(e=Ut(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!==jt.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=Ut(t))||void 0===i?void 0:i.bucket})).filter((t=>void 0!==t));if(0===s.length)return;if(this.config.interval!==td)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!==jt.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 nf{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=Ot.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereOf=[],this.thereOfPosition=Nt.BELOW,this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new st(new Tl).default(),this.type=At.LIST,this.limit=0,this.i18n=Lt.ALL,this.categoryWidth=Tt.W25,this.measureScale=new La,this.measureUnit="",this.measureType=Et.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class rf{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 nf;return R.isString(t.title)&&(i.title=t.title),R.isArray(t.scenarios)&&(i.scenarios=it.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.runningSum)&&(i.runningSum=t.runningSum),R.isBoolean(t.varianceWaterfall)&&(i.varianceWaterfall=t.varianceWaterfall),t.thereOfPosition===Nt.ABOVE&&(i.thereOfPosition=Nt.ABOVE),R.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),R.isArray(t.thereOf)&&(i.thereOf=it.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),R.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),R.isArray(t.partOf)&&(i.partOf=it.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 nf}}class of{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class hf{constructor(){}adapt(t){const i=new of;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 of}}const af=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=Ot.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereof=[],this.thereofPosition=Nt.BELOW,this.partof=[],this.order={hierarchy:[],direction:Gt.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=At.LIST,this.categoryWidth=Tt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=Lt.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=Et.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 oc,this.blockStarts=new Set,this.barColumnLayouts=new Map,this.waterfallGeometries=new Map,this.relayout=()=>{(this.barColumnLayouts.size>0||this.waterfallGeometries.size>0)&&n(this)},l(this),this.componentStyle=N(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:li(h,t)}),a&&r.regions.push({id:"body",rect:li(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:li(o,t),point:ls(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:li(h,t),point:ls(h)};l.point&&(l.content=gi(h,t),l.contentSign=mi(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:li(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",{class:{"grouped-list":this.groupedList()},style:{"--bn-block-gap":.6*this.emPx()+"px"}},i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map(((t,s,e)=>i("th",{colSpan:t.colSpan,class:`${t.cssStyle}${this.isBarColumn(t.key)?" barColumn":""}${this.blockStartClass(e,s)}`},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},as(t.key,"element")),null==t?void 0:t.getCells().map(((s,e,n)=>{var o,h,a,l,c;return i("td",Object.assign({colSpan:s.colSpan,class:(s.type?`${this.cellClass(s,r)} ${s.type}`:s.cssStyle)+this.blockStartClass(n,e)},t.key&&null!=s.value&&""!==s.value&&"-"!==s.value?as(Object.assign(Object.assign({},t.key),{date:s.date,scenario:s.key}),"element"):{}),null!=s.prefix?i("span",{class:this.cellClass(s,r)+" "+s.prefixStyle},s.drawPrefix()):"",!s.isBarChart||!s.columnStats||s.value===et||!this.showGroupTitle&&t.type===Dt.HEADER||void 0===s.waterfall&&t.type===Dt.SUM||void 0!==s.direction&&s.waterfall&&s.waterfall.max===s.waterfall.min?s.draw(this.componentDataFormatDigits,r):void 0!==s.waterfall?i(Id,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===s.direction,measureScale:cf(s),locale:r,decimalDigits:uf(s,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall,geometry:this.waterfallGeometries.get(s.key),bold:lf(t),connectorReach:this.connectorReach(t)}):i(Gd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:"pos"===s.direction,measureScale:cf(s),locale:r,decimalDigits:uf(s,this.componentDataFormatDigits),percentDigits:null!==(h=null===(o=this.barColumnLayouts.get(s.key))||void 0===o?void 0:o.percentDigits)&&void 0!==h?h:this.componentDataFormatDigits.percent,percentSign:null===(a=this.barColumnLayouts.get(s.key))||void 0===a?void 0:a.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(l=this.barColumnLayouts.get(s.key))||void 0===l?void 0:l.labels,sideMax:null===(c=this.barColumnLayouts.get(s.key))||void 0===c?void 0:c.sideMax,bold:lf(t),styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,i,s,e,n,r,o,h,a,l,c;this.stores||(this.stores=u(this.element));const d=this.stores.db.db;this.componentDataFormatDigits=(new hc).adapt(this.dataFormatDigits);try{const i=this.prepareConfig(d);this.table=new ef(new se(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===(c=this.errors)||void 0===c||c.remove(t);this.blockStarts=this.collectBlockStarts(),this.barColumnLayouts=this.collectBarColumnLayouts(),this.waterfallGeometries=this.collectWaterfallGeometries(),this.barChartStyles=this.prepareBarChartStyles()}collectBlockStarts(){const t=new Set;if(!this.table||this.table.hasNoData())return t;const i=this.table.getColumns().map((t=>{var i;const s=new Xs(t.type),e=s.isValid?`${s.base}_${s.delta}`:/^(ac|pp|fc|pl)\d/i.test(t.type)?"scenario":"rowheader";return`${null!==(i=t.bucket)&&void 0!==i?i:""}|${e}`}));return i.forEach(((s,e)=>{e>0&&s!==i[e-1]&&t.add(e)})),t}blockStartClass(t,i){let s=0;for(let e=0;e<i;e++)s+=t[e].colSpan;return this.blockStarts.has(s)?" block-start":""}groupedList(){return!0===this.grouped&&this.type!==At.OPT&&this.type!==At.OPTNOTOTAL}isBarColumn(t){return this.barColumns.includes(t)}cellClass(t,i){return void 0!==t.direction&&t.roundsToZero(this.componentDataFormatDigits,i)?t.cssStyle.replace(/^(pos|neg)_\w+/,"zero"):t.cssStyle}prepareConfig(t){var i,s,e;const n=M(t,this.tableName,this.filter);return new rf(new hf,new Tl,new st(new Tl,!0),t,n,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereOf:this.thereof,thereOfPosition:this.thereofPosition,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,categoryIntervalPosition:this.categoryIntervalPosition,locale:(null===(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,_,k,O,N;const A=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,R=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==A?void 0:A.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(o=null==A?void 0:A.pos)||void 0===o?void 0:o.fill)||"#008f96",fillpattern:he(null===(h=null==A?void 0:A.pos)||void 0===h?void 0:h.fillpattern)||"solid"},negative:{stroke:(null===(a=null==A?void 0:A.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(l=null==A?void 0:A.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:he(null===(c=null==A?void 0:A.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==A?void 0:A.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==A?void 0:A.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:he(null===(f=null==A?void 0:A.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:te({ac:{stroke:(null===(v=null==R?void 0:R.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===(p=null==R?void 0:R.ac)||void 0===p?void 0:p.fill)||"#404040",fillpattern:he(null===(g=null==R?void 0:R.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==R?void 0:R.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==R?void 0:R.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:he(null===(y=null==R?void 0:R.pp)||void 0===y?void 0:y.fillpattern)||"solid"},fc:{stroke:(null===(w=null==R?void 0:R.fc)||void 0===w?void 0:w.stroke)||"#404040",fill:(null===(x=null==R?void 0:R.fc)||void 0===x?void 0:x.fill)||"#ffffff",fillpattern:he(null===(S=null==R?void 0:R.fc)||void 0===S?void 0:S.fillpattern)||"hatched"},pl:{stroke:(null===($=null==R?void 0:R.pl)||void 0===$?void 0:$.stroke)||"#404040",fill:(null===(M=null==R?void 0:R.pl)||void 0===M?void 0:M.fill)||"#ffffff",fillpattern:he(null===(_=null==R?void 0:R.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new se(this.ruleSetConfig)),fontColor:(null===(k=t.global)||void 0===k?void 0:k.fontColor)||"#000000",fontSize:((null===(O=t.global)||void 0===O?void 0:O.fontSizePx)||13.3333)*ld*this.scaleFactor,emPx:((null===(N=t.global)||void 0===N?void 0:N.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*ld;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=xd(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*ld;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=8*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!==Dt.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:[],{cell:s,bold:lf(i)}]));const o=this.emPx(),h=o*ld,a=8*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((({cell: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=Cd(o);for(const{cell:e,bold:u}of i){const i=e.value,d=i>0||0===i&&a?"pos":"neg",f=Ad(i,s,cf(e),l,t,n,uf(e,this.componentDataFormatDigits));o[d]=Math.max(null!==(r=o[d])&&void 0!==r?r:0,pd(f,h,c,s,u))}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)&&!yd(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}connectorReach(t){const i=this.emPx(),s=this.groupedList()?1:.5;return{top:.1*i,bottom:t.type===Dt.SUM?s*i:0}}collectWaterfallGeometries(){var t,i,s,e;const n=new Map;if(!this.table||this.table.hasNoData())return n;const r=this.emPx(),o=r*ld,h=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,a=this.labelFontFamily(),l=new Map;for(const t of this.table.getBody())for(const i of t.getCells()){if(!i.isBarChart||!i.columnStats||void 0===i.waterfall)continue;if("number"!=typeof i.value||isNaN(i.value))continue;const{start:s,end:n,min:r,max:c,kind:u}=i.waterfall,d=jd(i.value,u,cf(i),h,uf(i,this.componentDataFormatDigits),void 0!==i.direction),f=null!==(e=l.get(i.key))&&void 0!==e?e:{min:r,max:c,labels:[]};f.labels.push({end:n,pointsLeft:n<s,width:pd(d,o,a,!1,lf(t))}),l.set(i.key,f)}for(const[t,i]of l)n.set(t,$d(this.barColumnMaxWidth,r,i));return n}get element(){return e(this)}};function lf(t){return t.type===Dt.SUM||"ofit-sum"===t.cssStyle}function cf(t){return"percentpoint"===t.type?.01:t.measureScale}function uf(t,i){return"percentpoint"===t.type?i.percent:"decimal"===t.type?i.decimal:void 0}af.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,td.zero{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}tr.partof td.percentpoint{font-style:italic}tr.partof td.percentpoint:after{content:"%p"}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.barColumn{text-align:center}td.block-start,th.block-start{border-left:var(--bn-block-gap, 0) solid transparent;clip-path:inset(-100em -100em -100em var(--bn-block-gap, 0))}.category-w100.block-start{min-width:calc(100em + var(--bn-block-gap, 0px));max-width:calc(100em + var(--bn-block-gap, 0px))}.category-w50.block-start{min-width:calc(50em + var(--bn-block-gap, 0px));max-width:calc(50em + var(--bn-block-gap, 0px))}.category-w25.block-start{min-width:calc(25em + var(--bn-block-gap, 0px));max-width:calc(25em + var(--bn-block-gap, 0px))}.category-w20.block-start{min-width:calc(20em + var(--bn-block-gap, 0px));max-width:calc(20em + var(--bn-block-gap, 0px))}.category-w15.block-start{min-width:calc(15em + var(--bn-block-gap, 0px));max-width:calc(15em + var(--bn-block-gap, 0px))}.category-w10.block-start{min-width:calc(10em + var(--bn-block-gap, 0px));max-width:calc(10em + var(--bn-block-gap, 0px))}.category-w5.block-start{min-width:calc(5em + var(--bn-block-gap, 0px));max-width:calc(5em + var(--bn-block-gap, 0px))}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}table.grouped-list tr.sum td{padding-bottom:1em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.sum td.pos_pos,tr.sum td.pos_neg,tr.sum td.neg_pos,tr.sum td.neg_neg,tr.ofit-sum td.pos_pos,tr.ofit-sum td.pos_neg,tr.ofit-sum td.neg_pos,tr.ofit-sum td.neg_neg{color:inherit}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.cell-bar-chart),tr.partof td:has(.cell-bar-chart),tr.share td:has(.cell-bar-chart){padding:0 0.4166666667em}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';const df=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",E(this),l(this),this.t=ti(this).t,this.errors=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this)}validateScenario(t){const i="WARN_scenarios",s=V(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=X(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=F(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";G(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=It(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";Bt(t)||L(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";Bt(t)||L(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";ot(t)||L(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";Yt(t)||L(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=g,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(),...ie(this.ruleSetConfig("user"))])}prepareI18nMode(){return Lt.META}prepareLocale(){return u(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return L(this.order)||L(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:I[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return L(this.dateStart)&&L(this.dateEnd)||L(this.dateLink)?null:{start:w.fromISO(this.dateStart,{zone:"utc"}),end:w.fromISO(this.dateEnd,{zone:"utc"}),format:at[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Ht[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){if(L(this.measures))return[];try{return JSON.parse(this.measures)}catch(t){return[]}}prepareScenarios(){var t,i,s,e;if(L(this.scenarios)&&L(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 L(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":`${this.titleFontSize>0?this.titleFontSize:(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:"999f282ecc2901b62f051e0501da7dd41f44a30a",style:t},i("bn-title-renderer",{key:"2c58cbb472fc807a83503e7789babce4b17b1081",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}]}}};df.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 ff{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===Lt.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 ut;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(" ",Oa.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 vf{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=Lt.ALL,this.intervalSpanLimit=32,this.locale="de"}}class pf{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new vf;return R.isString(t.businessunit)&&(i.businessunit=t.businessunit),R.isArray(t.measures)&&(i.measures=it.adaptArray(t.measures,this.measureEntryAdapter)),R.isArray(t.scenarios)&&(i.scenarios=it.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 vf}}var gf;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(gf||(gf={}));class mf{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new vf,this.state=gf.DIRTY,this.ruleSet=t||new se,this.dataSetFactory=new ff,this.state=gf.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new se}setI18n(t){this.state=gf.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 gf.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=gf.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=gf.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class bf{constructor(t="",i=""){this.name=t,this.unit=i}}class yf{construnctor(){}adapt(t){const i=new bf;return R.isString(t.name)&&(i.name=t.name),R.isString(t.unit)&&(i.unit=t.unit),i}default(){return new bf("","")}}class wf{constructor(t=w.now(),i=w.now(),s=at.AUTO,e=Ht.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class xf{construnctor(){}adapt(t){const i=new wf;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 wf}}const Sf=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:I.ASC},this.i18n=new Map,this.i18nMode=Lt.ALL,this.locale="de",this.title=new mf(new se),l(this)}render(){return i("div",{key:"ecc33a660538732ceea3e4620afabfcb8ffbce95"},i("div",{key:"cb1c3b074817a4c0647419fdc0f2b94c113ebc09",innerHTML:Vt(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 mf(new se(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 se(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new pf(new yf,new xf,new st(new Tl),new Tl).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})}};Sf.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 $f=["*","/","+","-","x","÷","none"];function Mf(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function _f(t,i,s){return t.find((t=>t.from===i&&t.to===s))}function kf(t){return 2*(t-1)+1}function Of(t){return 2*(t-1)+1}function Nf(t){return t<=1?1:2*(t-1)+1}function Af(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 Rf(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 Lf(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 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 Cf(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 Pf(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 Wf=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&&$f.includes(o.operator)||i.push(`edges[${s}]: 'operator' must be one of: ${$f.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";!rt(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";!rt(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),l(this),this.errors=c(this),this.componentStyle=N(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=di(this.element),v=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),p={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(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:ai(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:li(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:li(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:li(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:li(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=$s(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,Af(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=Xt(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=Jt(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(kf(i.gridColumn)),"grid-row":`${Of(i.gridRow)} / span ${Nf(i.gridRowSpan)}`,"align-self":"center"}:{"grid-row":String(Of(i.gridRow)),"grid-column":`${kf(i.gridColumn)} / span ${s=i.gridColumnSpan,Nf(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=Rf(n,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const i=l.indexOf(t.from);c=Lf(h,this.direction,i,l.length)}else c=Rf(h,!1,this.direction);const{path:u}=Tf(a,c,this.edgeStyle,this.direction,o.get(t.from)),d=Pf(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=_f(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:Mf(c.operator),v=Cf(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","data-bn-fit-content":"",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}]}}};Wf.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{Ji as bn_annotation_layer,qi as bn_annotation_list,Ki as bn_asset,Qi as bn_body,Zi as bn_card,Vs as bn_chart_bubble,Qa as bn_chart_bubble_renderer,hl as bn_chart_bullet,gl as bn_chart_bullet_renderer,bl as bn_chart_scatter,Sl as bn_chart_scatter_renderer,$l as bn_chart_structure,ac as bn_chart_structure_renderer,lc as bn_chart_time,Ic as bn_chart_time_renderer,Bc as bn_component_style,su as bn_context,Wu as bn_dataset,Du as bn_datasource,zu as bn_footer,Xu as bn_layout_card,Ju as bn_layout_page,qu as bn_message,Ku as bn_page,Qu as bn_scaling_group,rd as bn_table,af as bn_table_renderer,df as bn_title,Sf as bn_title_renderer,Wf as bn_tree}
1
+ import{r as t,h as i,a as s,g as e,f as n,d as r,e as o,F as h}from"./p-GstO_GU5.js";import{S as a,w as l,a as c,g as u,C as d,r as f,c as v,h as p,d as g,e as m,X as b,i as y,D as w,j as x,m as S,s as $,k as M,l as _,u as k,n as O}from"./p-B6SpWzpW.js";import{a as N,m as A,C as R,i as L,b as T,w as E,c as P,r as C,s as W,d as D,e as z,f as U,v as F,g as G,A as j,O as I,h as B,j as Y,k as H,l as V,n as X,o as J,p as q,q as K,S as Q,t as Z,u as tt,x as it,y as st,N as et,z as nt,B as rt,D as ot,E as ht,F as at,G as lt,H as ct,I as ut,R as dt,J as ft,K as vt,L as pt,M as gt,P as mt,Q as bt,T as yt,U as wt,V as xt,W as St,X as $t,Y as Mt,Z as _t,_ as kt,$ as Ot,a0 as Nt,a1 as At,a2 as Rt,a3 as Lt,a4 as Tt,a5 as Et,a6 as Pt,a7 as Ct,a8 as Wt,a9 as Dt,aa as zt,ab as Ut,ac as Ft,ad as Gt,ae as jt,af as It,ag as Bt,ah as Yt,ai as Ht}from"./p-BXkVoFbt.js";import{s as Vt,g as Xt,b as Jt,i as qt,f as Kt,r as Qt,a as Zt,w as ti,p as ii,c as si,d as ei,e as ni,h as ri,j as oi}from"./p-DBRtHV59.js";import{w as hi}from"./p-CZmA8CIL.js";import{r as ai,m as li,a as ci,l as ui,o as di,b as fi,c as vi,t as pi,d as gi,e as mi}from"./p-CzzF-PBk.js";import{L as bi}from"./p-DY5fMUX8.js";import{e as yi,r as wi}from"./p-ClruFZD_.js";import{I as xi,S as Si,D as $i,b as Mi}from"./p-hV2evPFR.js";const _i=/^[a-z][a-z0-9-]*$/i;function ki(t,i){var s,e;const n=null!==(s=null==i?void 0:i.color)&&void 0!==s?s:a["bn-annotation"].color,r=null!==(e=null==i?void 0:i.colors)&&void 0!==e?e:{},o=`var(--bn-annotation-color, ${n})`;if(!t||!_i.test(t))return o;const h=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;return`var(--bn-annotation-color-${t}, ${null!=h?h:o})`}const Oi=t=>"string"==typeof t||"number"==typeof t?String(t):void 0;function Ni(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 Ai=new WeakMap;let Ri=1;function Li(t){const i=t.closest("bn-layout-page");if(!i)return"";let s=Ai.get(i);return s||(s="page-"+Ri++,Ai.set(i,s)),s}const Ti=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function Ei(t,i){const s=Ti(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 Pi(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 Ci=(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 Wi(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=>Ci(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))}}const Di=(t,i)=>.6*t.length*i,zi=(t,i)=>(t<0?"-":"+")+Math.abs(t).toFixed(i);function Ui(t,i,s,e,n,r,o){var h,a,l;if(null==e||null==n)return;const c=n-e,u=Number.isInteger(t.digits)&&t.digits>=0?t.digits:1,d="good-down"===t.sentiment?c<=0:c>=0,f=s.x+s.width/2>=i.x+i.width/2?1:-1,v=t=>1===f?t.x+t.width:t.x,p=v(s)+.9*f*r,g=p+.125*f*r,m=null!==(h=null==o?void 0:o.from)&&void 0!==h?h:i.y,b=null!==(a=null==o?void 0:o.to)&&void 0!==a?a:s.y,y=.25*r,w=t.percent&&0!==e?`(${zi(c/Math.abs(e)*100,0)}%)`:void 0,x=zi(c,u),S=p+.6*f*r,$=(m+b)/2,M=w?Di(w,.85*r):0,_=1===f?S+.5*x.length*r+.35*r:S-M;return{kind:"difference",color:null!==(l=t.color)&&void 0!==l?l:d?"positive":"negative",lines:[{x1:v(i),y1:m,x2:g,y2:m},{x1:v(s),y1:b,x2:g,y2:b}],bar:{x:p-y/2,y:Math.min(m,b),width:y,height:Math.max(Math.abs(b-m),1)},text:{x:S,y:$,anchor:1===f?"start":"end",value:x,percent:w},frame:w&&t.highlight?{x:_-.25*r,y:$-.65*r,width:M+.5*r,height:1.3*r,r:.65*r}:void 0,badge:null!=t.label?{cx:p,cy:Math.min(m,b)-.9*r,r:.65*r,label:t.label}:void 0}}function Fi(t,i,s,e,n={}){var r,o,h,a;const{label:l,color:c}=t,{whole:u,area:d,text:f}=n,v=!u&&!f&&null!=n.obstacles,p=((t,i)=>t?Math.min(i,t.height/1.3):i)(null!=f?f:v?i:void 0,e);if("arrow"===t.mark){if(!s)return;const t=Ti(i),n=Ti(s);if(t.x===n.x&&t.y===n.y)return;let r=Ei(i,n),o=Ei(s,t);(o.x-r.x)*(n.x-t.x)+(o.y-r.y)*(n.y-t.y)<=0&&(r=t,o=n);const h=Math.hypot(o.x-r.x,o.y-r.y),a=Math.min(.8*e,h),u=(o.x-r.x)/h,f=(o.y-r.y)/h,v=o.x-u*a,p=o.y-f*a,g=.35*e;return{kind:"arrow",color:c,x1:r.x,y1:r.y,x2:v,y2:p,head:[`${o.x},${o.y}`,`${v-f*g},${p+u*g}`,`${v+f*g},${p-u*g}`].join(" "),badge:null!=l?Pi({cx:r.x,cy:r.y,r:.65*e,label:l},d):void 0}}if("frame"===t.mark){const s=null==t.text||u?void 0:n.label?"above"===t.textPosition?{x:i.x+i.width/2+.5*e,y:i.y-.8*e}:{x:i.x+i.width+.7*e+Di(t.text,e)/2,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y+Math.min(i.height/2,Math.max(.9*e,.3*i.height))},h=s&&{x:s.x-Di(t.text,e)/2,y:s.y-.6*e,width:Di(t.text,e),height:1.2*e},a=null!==(r=null!=h?h:f)&&void 0!==r?r:i,v=null===(o=t.point)||void 0===o?void 0:o.part,g=!u&&(null!=h||null!=f||"label"===v||"total"===v),m=(g?.45:.2)*p,b=(g?.1:.2)*p,y=g?Math.max(a.width,a.height):a.width,w=a.x+a.width/2,x=1,S=Math.max(d?x:-1/0,w-y/2-m),$=Math.max(d?x:-1/0,a.y-b),M=Math.min(d?d.width-x:1/0,w+y/2+m),_=Math.min(d?d.height-x:1/0,a.y+a.height+b),k=Math.min(M-S,_-$)/2,O=u?.25*e:k,N=u?.25*e:g?Math.min((M-S)/2,1.6*k):k,A=1-Math.SQRT1_2,R=.65*p,L=g?.6*R:0;return{kind:"frame",color:c,x:S,y:$,width:M-S,height:_-$,rx:N,ry:O,badge:null!=l?Pi({cx:M-N*A+L,cy:$+O*A-L,r:R,label:l},d):void 0,caption:s&&Object.assign(Object.assign({},s),{text:t.text})}}if(f&&!u){const t=Wi(f,(null==l?.4:.65)*p,p,n);return{kind:"marker",color:c,badge:Pi({cx:t.x,cy:t.y,r:t.r,label:l},d)}}const g=(null==l?.4:.75)*p,m=v?Math.min(g,i.height/2):g;let b=u?{x:i.x+i.width-m,y:i.y+m}:Ti(i);if(!u&&n.label)b={x:i.x+i.width+.25*p+m,y:i.y+i.height/2};else if(!u&&n.stacked&&n.horizontal){const t=1.3*p+m;b=i.width/2>=t+m?{x:i.x+i.width/2+t,y:i.y+i.height/2}:{x:i.x+i.width-Math.min(m,i.width/2),y:i.y}}else!u&&n.stacked&&"label"!==(null===(h=t.point)||void 0===h?void 0:h.part)&&"total"!==(null===(a=t.point)||void 0===a?void 0:a.part)&&(b={x:i.x+i.width,y:i.y+Math.min(.5*m,i.height/2)});if(v){const t={x:b.x-m,y:b.y-m,width:2*m,height:2*m},i=n.obstacles.find((i=>Ci(t,i)));if(i){const t=Wi(i,m,p,n);return{kind:"marker",color:c,badge:Pi({cx:t.x,cy:t.y,r:t.r,label:l},d)}}}return{kind:"marker",color:c,badge:Pi({cx:b.x,cy:b.y,r:m,label:l},d)}}function Gi(t,i,s,e,n,r,o){var h;if(null==e||null==n)return;const a=n-e,l=Number.isInteger(t.digits)&&t.digits>=0?t.digits:1,c="good-down"===t.sentiment?a<=0:a>=0,u=s.y+s.height/2>=i.y+i.height/2?1:-1,d=t=>1===u?t.y+t.height:t.y,f=.25*r,v=d(s)+.25*u*r,p=Math.min(o.from,o.to),g=Math.max(o.from,o.to),m=t.percent&&0!==e?`(${zi(a/Math.abs(e)*100,0)}%)`:void 0,b=zi(a,l),y=g+.5*r,w=.5*b.length*r,x=m?Di(m,.85*r):0,S=y+w+.35*r;return{kind:"difference",color:null!==(h=t.color)&&void 0!==h?h:c?"positive":"negative",lines:[{x1:o.from,y1:d(i),x2:o.from,y2:v},{x1:o.to,y1:d(s),x2:o.to,y2:v}],bar:{x:p,y:v-f/2,width:Math.max(g-p,1),height:f},text:{x:y,y:v,anchor:"start",value:b,percent:m},frame:m&&t.highlight?{x:S-.25*r,y:v-.65*r,width:x+.5*r,height:1.3*r,r:.65*r}:void 0,badge:null!=t.label?{cx:p-.9*r,cy:v,r:.65*r,label:t.label}:void 0}}function ji(t,i,s){const e=i.x,n=i.y-.15*s,r=n-.7*s,o=n-1.9*s,h=.55*s,a=.22*s;return{kind:"pointer",color:t.color,shape:[[e,n],[e-h,r],[e-a,r],[e-a,o],[e+a,o],[e+a,r],[e+h,r]].map((([t,i])=>`${t},${i}`)).join(" "),badge:null!=t.label?{cx:e+1.1*s,cy:o+.65*s,r:.65*s,label:t.label}:void 0}}function Ii(t,i,s,e,n,r,o){const h=i.y<=s.y,[a,l]=h?[i,s]:[s,i],[c,u]=h?[e.first,e.last]:[e.last,e.first],d=l.y+l.height+.2*o,f=[[n,d],[u,d],[c,a.y-.1*o]],v=r?Di(r,o):0,p=(a.y+l.y+l.height)/2,g=r?{x:n+.5*o+v/2,y:p,text:r}:void 0,m=g?g.x+v/2+1.2*o:n+.65*o;return{kind:"bracket",color:t.color,path:f.map((([t,i])=>`${t},${i}`)).join(" "),caption:g,frame:g&&{x:g.x-v/2-.45*o,y:g.y-.7*o,width:v+.9*o,height:1.4*o,r:.7*o},badge:null!=t.label?{cx:m,cy:p,r:.65*o,label:t.label}:void 0}}const Bi=["rowGroup","category","subCategory","date","scenario","row"];function Yi(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"))&&Bi.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,value:e,scenario:n,kind:r})=>({rect:t,content:i,contentSign:s,value:e,stacked:"string"==typeof n&&n.startsWith("stack:"),label:"label"===r})))}function Hi(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 Vi=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function Xi(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 Ji=class{constructor(i){t(this,i),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.observedAround=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=l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){var t;this.stores=u(this.element),this.pageKey=Li(this.element),this.observed=new WeakSet,this.observedAround=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=Ni(t))||void 0===i?void 0:i.map((t=>{var i;return Object.assign(Object.assign({},t),{label:Oi(t.label),color:Oi(t.color),target:null!==(i=Oi(t.target))&&void 0!==i?i:"",to:Oi(t.to),text:Oi(t.text)})}))}(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,i,s,e;const n=++this.run;if(!this.element.isConnected||!this.svg)return;const r=this.element.closest("bn-layout-page"),o=new Map,h=new Map;null==r||r.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const i=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!Vi.has(t.localName))),s=null!=i?i:t;o.set(t.getAttribute("data-bino-annotation-target"),s),h.set(s,t)})),null==r||r.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const a=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),l=[...o].filter((([t])=>a.has(t))).map((([,t])=>t));if(await Promise.all(l.map((t=>{var i;return null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t)}))),n!==this.run)return;l.forEach((t=>{this.observe(t),this.observeAround(t,r)}));const c=new Map;if(await Promise.all(l.map((async t=>{var i;c.set(t,await(null===(i=t.getLayoutState)||void 0===i?void 0:i.call(t,{detail:"full"}).catch((()=>{}))))}))),n!==this.run)return;const u=(t,i)=>{var s;const e=null!=t?o.get(t):void 0;if(!e)return{problem:`no target "${t}" on this page`};const n=e.getBoundingClientRect();if(function(t){return!t||Bi.every((i=>null==t[i]))&&null==t.part}(i)){const i={x:n.left,y:n.top,width:n.width,height:n.height};return function(t,i,s){if(0===t.width||0===t.height||!Xi(t,s))return!0;for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Xi(t,s))return!0;return!1}(i,h.get(e),this.element)?{problem:`"${t}" cannot be seen`}:{box:i,whole:!0}}const r=c.get(e),a=r?Yi(r,i):[];if(1!==a.length)return{problem:`${a.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const l=({component:{x:t,y:i,width:s,height:e}})=>({x:n.left+t,y:n.top+i,width:s,height:e}),u=l(a[0].rect);if(function(t,i){for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Hi(t,s))return!0;return!1}(u,h.get(e))||!Hi(u,this.element))return{problem:`the point ${JSON.stringify(i)} in "${t}" is cut off`};const f=a[0].content;if(!r.table)return{box:u,whole:!1,stacked:a[0].stacked,label:a[0].label,horizontal:d(r)};const v=(null!==(s=r.elements)&&void 0!==s?s:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:l(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:f&&{box:l(f),sign:a[0].contentSign},obstacles:v}},d=t=>{var i;return(null!==(i=null==t?void 0:t.elements)&&void 0!==i?i:[]).some((t=>"axis"===t.kind&&"vertical"===t.orientation))},f=(t,i)=>{const s=null!=t?o.get(t):void 0;if(!s)return{problem:`no target "${t}" on this page`};const e=c.get(s),n=(e&&i?Yi(e,Object.assign(Object.assign({},i),{part:"element"})):[]).filter((t=>null!=t.value));if(0===n.length)return{problem:`no bar with a value matches the point ${JSON.stringify(i)} in "${t}"`};if(n.length>1&&!n.every((t=>t.stacked)))return{problem:`${n.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const r=s.getBoundingClientRect(),h=Math.min(...n.map((t=>t.rect.component.x))),a=Math.min(...n.map((t=>t.rect.component.y))),l=Math.max(...n.map((t=>t.rect.component.x+t.rect.component.width))),u=Math.max(...n.map((t=>t.rect.component.y+t.rect.component.height)));return{box:{x:r.left+h,y:r.top+a,width:l-h,height:u-a},negatives:n.filter((t=>t.value<0)).map((t=>{return{x:r.left+(i=t.rect.component).x,y:r.top+i.y,width:i.width,height:i.height};var i})),value:n.reduce(((t,i)=>t+i.value),0),horizontal:d(e)}},v=(t,i,s)=>{const e=o.get(t.target),n=e&&c.get(e);if(!e||!n||!t.point)return;const r=e.getBoundingClientRect(),h=function(t,i){var s={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(s[e[n]]=t[e[n]])}return s}(t.point,["rowGroup","category","subCategory","date"]),a=Yi(n,Object.assign(Object.assign({},h),{part:"element"})).filter((t=>null!=t.value)),l=a.reduce(((t,i)=>t+i.value),0),u=a.filter((t=>{const e=r.top+t.rect.component.y+t.rect.component.height/2;return e>=i.y&&e<=s.y+s.height})).reduce(((t,i)=>t+i.value),0);return 0!==l?u/l:void 0},p=this.toLocalSpace(),g=({box:t,sign:i=0})=>{const s=p(t);return Object.assign(Object.assign({},s),{x:s.x-i,width:s.width+i})},m=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,b={width:this.element.clientWidth,height:this.element.clientHeight},y=[],w=[];for(const n of this.parsedItems){if("difference"===n.mark){const i=f(n.target,n.point),s=f(null!==(t=n.to)&&void 0!==t?t:n.target,n.toPoint),e="problem"in i?i:"problem"in s?s:void 0;if(e){w.push({item:n,problem:e.problem});continue}const[r,o]=[i,s];if(r.horizontal){const t=t=>{const i=p(t.box);return i.x+i.width-t.negatives.reduce(((t,i)=>t+p(i).width),0)},i=Gi(n,p(r.box),p(o.box),r.value,o.value,m,{from:t(r),to:t(o)});i&&y.push(i);continue}const h=t=>p(t.box).y+t.negatives.reduce(((t,i)=>t+p(i).height),0),a=Ui(n,p(r.box),p(o.box),r.value,o.value,m,{from:h(r),to:h(o)});a&&y.push(a);continue}if("pointer"===n.mark||"bracket"===n.mark){const t=f(n.target,n.point),e="bracket"===n.mark?f(null!==(i=n.to)&&void 0!==i?i:n.target,n.toPoint):t,r="problem"in t?t:"problem"in e?e:void 0;if(r){w.push({item:n,problem:r.problem});continue}const[h,a]=[t,e],l=t=>{const i=p(t.box);return t.horizontal?{x:i.x+i.width-t.negatives.reduce(((t,i)=>t+p(i).width),0),y:i.y}:{x:i.x+i.width/2,y:i.y+t.negatives.reduce(((t,i)=>t+p(i).height),0)}};if("pointer"===n.mark){y.push(ji(n,l(h),m));continue}if(!h.horizontal){w.push({item:n,problem:"a bracket needs bars that run from left to right"});continue}if(null!=n.to&&n.to!==n.target){w.push({item:n,problem:"both ends of a bracket must be in one chart"});continue}const[c,u]=h.box.y<=a.box.y?[h.box,a.box]:[a.box,h.box],d=n.percent?v(n,c,u):void 0,g=o.get(n.target).getBoundingClientRect(),b=p({x:g.left,y:g.top,width:g.width,height:g.height}),x=null!==(s=n.text)&&void 0!==s?s:null!=d?`${Math.round(100*d)}%`:void 0;y.push(Ii(n,p(h.box),p(a.box),{first:l(h).x,last:l(a).x},b.x,x,m));continue}const r=u(n.target,n.point),h="arrow"===n.mark?u(n.to,n.toPoint):void 0,a="problem"in r?r:h&&"problem"in h?h:void 0;if(a){w.push({item:n,problem:a.problem});continue}const l=r,c=h,d=Fi(n,p(l.box),c&&p(c.box),m,{whole:l.whole,area:b,text:l.text&&g(l.text),obstacles:null===(e=l.obstacles)||void 0===e?void 0:e.map(g),stacked:l.stacked,label:l.label,horizontal:l.horizontal});d?y.push(d):w.push({item:n,problem:"an arrow needs two ends at different places"})}this.marks=y,this.storeUnplaced(w.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),w.length>0&&this.reportWhenQuiet(n,w)}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===d.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)}observeAround(t,i){var s,e;for(let n=t.parentElement;n&&n!==i;n=n.parentElement)this.observedAround.has(n)||(this.observedAround.add(n),null===(s=this.mutationObserver)||void 0===s||s.observe(n,{attributes:!0,attributeFilter:["style"]}),n.shadowRoot&&(null===(e=this.mutationObserver)||void 0===e||e.observe(n.shadowRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})))}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){var e;if(!t)return null;const n="outlined"===(null===(e=this.componentStyle((t=>t["bn-annotation"])))||void 0===e?void 0:e.markerStyle),r=i("circle",n?{cx:t.cx,cy:t.cy,r:t.r-.75,style:{fill:"#ffffff",stroke:s,strokeWidth:"1.5"}}:{cx:t.cx,cy:t.cy,r:t.r,style:{fill:s}});return i("g",null,r,null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:Object.assign({fontSize:1.1*t.r+"px"},n?{fill:s}:{})},t.label):null)}renderMark(t){var s,e,n,r,o;const h=ki(t.color,this.componentStyle((t=>t["bn-annotation"])));if("marker"===t.kind)return i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,h));if("frame"===t.kind)return 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:t.caption?"#ffffff":"none",stroke:h,strokeWidth:"1.5"}}),t.caption?i("text",{class:"mark-text caption",x:t.caption.x,y:t.caption.y},t.caption.text):null,this.renderBadge(t.badge,h));if("difference"===t.kind){const s=ki(void 0,this.componentStyle((t=>t["bn-annotation"])));return i("g",{class:"mark difference","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},t.lines.map((t=>i("line",{class:"difference-line",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}))),i("rect",{x:t.bar.x,y:t.bar.y,width:t.bar.width,height:t.bar.height,style:{fill:h}}),i("text",{class:"mark-text",x:t.text.x,y:t.text.y,style:{textAnchor:t.text.anchor}},t.text.value,t.text.percent?i("tspan",{class:"percent",dx:"0.35em"},t.text.percent):null),t.frame?i("rect",{x:t.frame.x,y:t.frame.y,width:t.frame.width,height:t.frame.height,rx:t.frame.r,ry:t.frame.r,style:{fill:"none",stroke:s,strokeWidth:"1.5"}}):null,this.renderBadge(t.badge,s))}return"pointer"===t.kind?i("g",{class:"mark pointer","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},i("polygon",{points:t.shape,style:{fill:h}}),this.renderBadge(t.badge,h)):"bracket"===t.kind?i("g",{class:"mark bracket","data-label":null===(r=t.badge)||void 0===r?void 0:r.label},i("polyline",{points:t.path,style:{fill:"none",stroke:h,strokeWidth:"1.5"}}),t.frame?i("rect",{x:t.frame.x,y:t.frame.y,width:t.frame.width,height:t.frame.height,rx:t.frame.r,ry:t.frame.r,style:{fill:"#ffffff",stroke:h,strokeWidth:"1.5"}}):null,t.caption?i("text",{class:"mark-text caption",x:t.caption.x,y:t.caption.y},t.caption.text):null,this.renderBadge(t.badge,h)):i("g",{class:"mark arrow","data-label":null===(o=t.badge)||void 0===o?void 0:o.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:h,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:h}}),this.renderBadge(t.badge,h))}render(){return i(s,{key:"370b2e099f2316d584f40b02b417576ecc541291"},i("svg",{key:"ba77a53b8fe0b9dbabe25d070a87a1841ed19998",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return e(this)}static get watchers(){return{items:[{onItemsChange:0}]}}};Ji.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}.mark-text{fill:#000000;dominant-baseline:central}.mark-text.caption{text-anchor:middle;font-size:0.9em}.mark-text .percent{font-size:0.85em}.difference-line{stroke:#000000;stroke-width:0.75}';const qi=class{constructor(i){t(this,i),this.pageKey="",l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){this.stores=u(this.element),this.pageKey=Li(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=Ni(t))||void 0===i?void 0:i.map((t=>({label:Oi(t.label),title:Oi(t.title),html:Oi(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=this.componentStyle((t=>t["bn-annotation"])),o=ki(void 0,r),h="outlined"===(null==r?void 0:r.markerStyle)?{background:"#ffffff",color:o,boxShadow:`inset 0 0 0 1.5px ${o}`}:{background:o},a=null!==(e=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==e?e:[];return i(s,{key:"ec249c8259923180f4bd30b8c712c0614a758911"},i("ol",{key:"6e8cbbe5a5841c8707081f9452b11c3971cecd03"},(null!=n?n:[]).map((t=>i("li",null,null==t.label||a.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:h},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:Vt(t.html)}):null))))))}get element(){return e(this)}};qi.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 Ki=class{constructor(i){t(this,i),l(this),this.errors=c(this),hi(this,(t=>{this.stores||(this.stores=u(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)}};Ki.style=":host{display:none}";const Qi=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(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)}};Qi.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 Zi=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(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 ts(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return a.global.fontSizePx}function is(t,i){var s;return{version:bi,tag:t.localName,id:ci(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(t,i),em:{fontSizePx:ts(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:ai(t)}}Zi.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 ss="data-bn-baseline",es=t=>Math.round(100*t)/100;function ns(t,i){const s=t.querySelector(`[${ss}]`),e=null!=s?s:t.querySelector('g[id="axis"] line');if(!e)return{};const n=ui(i);return"frame"===e.getAttribute(ss)?function(t,i){const s=i.toLocal(t.getBoundingClientRect());return{x:es(s.x),y:es(s.y+s.height)}}(e,n):function(t,i){const s=i.toLocal(t.getBoundingClientRect());return s.width>=s.height?{x:es(s.x),y:es(s.y+s.height/2)}:{x:es(s.x+s.width/2),y:es(s.y)}}(e,n)}function rs(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?ns(r,t):{}}const os=[["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"]],hs="data-bn-part";function as(t,i){const s={};if(!t)return s;for(const[i,e]of os){const n=t[i];null!=n&&""!==n&&(s[e]=String(n))}return i&&(s[hs]=i),s}function ls(t){const i=t.getAttribute(hs);if(!i)return;const s={part:i};for(const[i,e]of os){const n=t.getAttribute(e);null!=n&&(s[i]=n)}return s}function cs(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 us(t,i){return null==i?{}:t.startsWith("rowGroup")?{rowGroup:String(i)}:t.startsWith("subCategory")?{subCategory:String(i)}:{category:String(i)}}const ds=/^Scenario([1-4])$/,fs=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,vs='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function ps(t){const i=t.getAttribute("data-bn-value");if(null==i||""===i)return;const s=Number(i);return Number.isFinite(s)?s:void 0}function gs(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){const t=ds.exec(null!==(s=e.id)&&void 0!==s?s:"");if(t)return`scenario${t[1]}`;e=e.parentElement}}function ms(t){if(""===t)return;const i=Number(t.split("_")[0]);return Number.isFinite(i)?i:void 0}function bs(t){const i=t.getAttribute("data-bn-index");return null===i?void 0:Number(i)}function ys(t,i){var s;return(null!==(s=t.getAttribute("class"))&&void 0!==s?s:"").split(/\s+/).includes(i)}function ws(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:li(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(vs).forEach((t=>{const i=fs.exec(t.id);i&&t.querySelector("rect")&&s.add(i[1])})),s.size}(f),h.baseline=ns(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:gs(r,t),index:null!==(h=ms(r.id))&&void 0!==h?h:o,rect:li(r,s),point:ls(r),value:ps(r)};e.push(a)})),t.querySelectorAll(vs).forEach((t=>{var r,o,h;const a=fs.exec(t.id);if(!a||!t.querySelector("rect"))return;n.add(t);const l=ls(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:li(t,s),point:l,value:ps(t)};e.push(c)})),["DATA","SCENARIO"].forEach((r=>{t.querySelectorAll(`g[id$="_${r}_Label"]`).forEach(((t,o)=>{var h,a,l,c;if(ys(t,"hide"))return;const u=null!==(a=null===(h=t.textContent)||void 0===h?void 0:h.trim())&&void 0!==a?a:"";if(!u)return;n.add(t);const d={kind:"label",id:t.id,role:"DATA"===r?"data":"scenario",text:u,segment:i,index:null!==(l=ms(t.id))&&void 0!==l?l:o,rect:li(null!==(c=t.querySelector("text"))&&void 0!==c?c:t,s),point:ls(t)};e.push(d)}))})),t.querySelectorAll("[data-bn-part]").forEach(((r,o)=>{var h,a,l,c;if(n.has(r))return;const u=ls(r),d=null!==(h=bs(r))&&void 0!==h?h:function(t,i){var s;for(let e=t;e&&e!==i;e=e.parentElement){const t=ms(null!==(s=e.id)&&void 0!==s?s:"");if(void 0!==t)return t}}(r,t);if("element"===u.part){const t={kind:"point",series:u.scenario,index:null!=d?d:o,rect:li(r,s),point:u};return void e.push(t)}const f={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:d,rect:li(null!==(c=r.querySelector("text"))&&void 0!==c?c:r,s),point:u};e.push(f)})),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=li(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(ys(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:ys(n,"categories")?"title":"category",text:h,segment:i,rect:li(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:li(t,e)})}})),"full"===n&&(h.elements=a),h}function xs(t,i,s,e,n,r){var o,h,a,l;const c={version:bi,tag:t.localName,id:ci(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:li(t,n),em:e,regions:[],metadata:{title:s},diagnostics:ai(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:li(u,n)}),c.metadata.pointCount=u.querySelectorAll("circle, ellipse").length,c.baseline=ns(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:li(t,i),point:ls(t)};s.push(n)})),t.querySelectorAll('rect[data-bn-part="element"]').forEach(((t,e)=>{var n;const r=ls(t),o={kind:"bar",segment:"base",scenario:null==r?void 0:r.scenario,index:null!==(n=bs(t))&&void 0!==n?n:e,rect:li(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:li(t,i),point:ls(t)};s.push(o)})),s}(u,n))),c}function Ss(t,i,s){var e,n,r,o,h;const a="WARN_overflow",l=Xt(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=Jt(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 $s(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 Ms=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])},c=()=>{const i=e(t),s=i.getAttribute("ruleset");if(a&&(a.disconnect(),a=null),s&&qt(s)){const e=Kt(i,s);if(r=Qt(e,"ruleset"),e.length>0){a=new MutationObserver((()=>{r=Qt(e,"ruleset"),l(),n(t)}));for(const t of e)a.observe(t,{attributes:!0,attributeFilter:["ruleset"]})}}else r=s},d=new MutationObserver((i=>{i.forEach((i=>{"ruleset"===i.attributeName&&(c(),l(),n(t))}))})),p=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=u(h),o=s.ruleSets.state._system,d.observe(h,{attributes:!0,attributeFilter:["ruleset"]}),c(),l(),i=s.ruleSets.on("set",(i=>{i!==r&&"_default"!==i||(c(),l(),n(e(t)))})),f(p,t)};const g=t.disconnectedCallback;return t.disconnectedCallback=()=>{d.disconnect(),a&&(a.disconnect(),a=null),f(i),v(e(t)),f(g,t)},(t="all")=>"user"===t?h:o},_s=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=u(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))})),f(o,t)};const h=t.disconnectedCallback;t.disconnectedCallback=()=>{f(i),v(e(t)),f(h,t)}};function ks(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 Ns(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 Rs=["measure","label","unit","min","max","refLine","highlight"];function Ls(t){const i=[],s=Ns(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Os(t,Rs),invalidFields:i};const e={measure:s.trim()};return e.label=Ns(t,"label",i),e.unit=Ns(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,Rs),invalidFields:i}}const Ts=["measure","label","unit","group"];function Es(t){const i=[],s=Ns(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Os(t,Ts),invalidFields:i};const e={measure:s.trim()};return e.label=Ns(t,"label",i),e.unit=Ns(t,"unit",i),e.group=Ns(t,"group",i),{config:e,unknownKeys:Os(t,Ts),invalidFields:i}}const Ps=["measure"];function Cs(t){const i=[],s=Ns(t,"measure",i);return void 0===s||""===s.trim()?(i.push("measure"),{config:null,unknownKeys:Os(t,Ps),invalidFields:i}):{config:{measure:s.trim()},unknownKeys:Os(t,Ps),invalidFields:i}}const Ws=["values","label","unit","highlight"];function Ds(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,Ws),invalidFields:i};const e={values:s};if(e.label=Ns(t,"label",i),e.unit=Ns(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,Ws),invalidFields:i}}const zs=["points","values","max"];function Us(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,zs),invalidFields:s}}const Fs=["level","columns"];function Gs(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,Fs),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,Fs),invalidFields:i}}const js=["show","position"];function Is(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,js),invalidFields:i}}function Bs(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 Ys={rowGroup:0,category:1,subCategory:2},Hs=["ac","pp","fc","pl"],Vs=class{validateFilter(t){const i="ERR_filter";p(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=>Ls(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>Ls(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>Es(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>Cs(t)))}validateCompareWith(t){const i="WARN_compareWith";L(t)||Hs.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' - expected ${Hs.join("/")}; ignored.`})}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];L(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"];L(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=>Gs(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>Us(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>Is(t)))}validateAspect(t){const i="WARN_aspect";L(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";T(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(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-bubble-renderer");const{mode:t}=ii(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}=Xt(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(){Ss(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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}=ks(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:"";P(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}=ks(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}=ks(i,"measure");if(e||null===s)return null;const{config:n}=Ls(s);return null!==n&&P(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}=ks(this.size,"measure");if(i||null===t)return null;const{config:s}=Es(t);return null!==s&&P(s.measure)?s:null}prepareShare(){const{data:t,parseError:i}=ks(this.share,"measure");if(i||null===t)return null;const{config:s}=Cs(t);return null!==s&&P(s.measure)?s:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return Hs.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:Us(i,t).config}prepareLegend(){const{data:t,parseError:i}=ks(this.legend,null);return i||null===t?{show:!0,position:"right"}:Is(t).config}prepareFacet(){const{data:t,parseError:i}=ks(this.facet,null);return i||null===t?null:Gs(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(W(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&&Ys[o]>=Ys[r]&&(a=`series '${o}' vs point '${r}'`),null!==h){const t=null!=o?o:r;Ys[h]>=Ys[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(g.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 rs(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=di(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 xs(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=Xt(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}]}}};Vs.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 Xs{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 Js(t,i,s){return"op"!==t&&"opinv"!==t?t:"op"===t!=(!s&&"-"===i)?"pos":"neg"}function qs(t){const i=[];for(const s of t){const t=new Xs(s);for(const s of t.isValid?[t.base,t.delta]:[])i.includes(s)||i.push(s)}return i}const Ks=["ac","pp","fc","pl"],Qs={10:"ac",20:"pp",30:"fc",50:"pl"};function Zs(t){var i;return null!==(i=Qs[t])&&void 0!==i?i:"ac"}function te(t,i){const s=Ks.map((t=>Zs(i.getScenarioColorIndex(`${t}1`))));if(s.every(((t,i)=>t===Ks[i])))return t;const e=Object.assign(Object.create(Object.getPrototypeOf(t)),t);return Ks.forEach(((i,n)=>{e[i]=t[s[n]]})),e}function ie(t){var i,s;const e=new Map;for(const n of Ks){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 se{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([m,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 Xs(t);return i.isValid?i.type+i.delta:t}}class ee{constructor(){this.font="16px Arial",this.family="Arial",this.size=16,this.color="#000000",this.background="#ffffff",this.leading=1.8}}class ne{adapt(t){const i=new ee;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 ee}}let re=class{constructor(){this.top=10,this.left=10,this.right=10,this.bottom=10}};class oe{adapt(t){const i=new re;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 re}}function he(t){return"fc"===t||"hatched"===t?"hatched":"solid"===t||"outlined"===t?t:void 0}class ae{constructor(t="#000000",i="#000000",s=.1){this.stroke=t,this.fill=i,this.width=s}}class le{adapt(t){const i=new ae(t.stroke,t.fill,t.width);return i.fillpattern=he(t.fillpattern),"outlined"===i.fillpattern&&(i.fill="transparent"),R.isString(t.dasharray)&&(i.dasharray=t.dasharray),i}default(){return new ae("#000000","#000000",.3)}defaultAC(){return new ae("#000000","#000000",.3)}defaultFC(){const t=new ae("#000000","#000000",.3);return t.dasharray="10 5 5 5",t.fillpattern="hatched",t}defaultPP(){return new ae("#999999","#999999",.3)}defaultPL(){return new ae("#000000","#ffffff",.3)}defaultPos(){return new ae("#00ff00","#00ff00",.3)}defaultNeg(){return new ae("#ff0000","#ff0000",.3)}defaultNeu(){return new ae("#999999","#999999",.3)}}class ce{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 ue{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new ce(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 ce(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL())}}class de{constructor(t,i,s,e){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.padding=e,this.seriesColors=[...b],this.locale="de"}}class fe{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 de(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class ve{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 pe{adapt(t){const i=new ve;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 ve}}var ge=Object.create,me=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyNames,we=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,Se=(t,i)=>()=>(i||(t((i={exports:{}}).exports,i),t=null),i.exports),$e=t=>{let i={};for(var s in t)me(i,s,{get:t[s],enumerable:!0});return me(i,Symbol.toStringTag,{value:"Module"}),i},Me=(t,i,s)=>(s=null!=t?ge(we(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var n,r=ye(i),o=0,h=r.length;o<h;o++)xe.call(t,n=r[o])||undefined===n||me(t,n,{get:(t=>i[t]).bind(null,n),enumerable:!(e=be(i,n))||e.enumerable});return t})(me(s,"default",{value:t,enumerable:!0}),t));const _e={},ke=[];function Oe(t,i){if(Array.isArray(t))for(const s of t)Oe(s,i);else if("object"!=typeof t)Ae(Object.getOwnPropertyNames(i)),_e[t]=Object.assign(_e[t]||{},i);else for(const i in t)Oe(i,t[i])}function Ne(t){return _e[t]||{}}function Ae(t){ke.push(...t)}var Re=Se(((t,i)=>{i.exports=function(t){try{return!!t()}catch(t){return!0}}})),Le=Se(((t,i)=>{var s=Re();i.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))})),Te=Se(((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)}}})),Ee=Se(((t,i)=>{var s=Te();i.exports=s({}.isPrototypeOf)})),Pe=Se(((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")()})),Ce=Se(((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)})})),We=Se(((t,i)=>{var s=Te(),e=s({}.toString),n=s("".slice);i.exports=function(t){return n(e(t),8,-1)}})),De=Se(((t,i)=>{var s=We(),e=Te();i.exports=function(t){if("Function"===s(t))return e(t)}})),ze=Se(((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}})),Ue=Se(((t,i)=>{var s=Re();i.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Fe=Se(((t,i)=>{var s=Le(),e=Function.prototype.call;i.exports=s?e.bind(e):function(){return e.apply(e,arguments)}})),Ge=Se((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})),je=Se(((t,i)=>{i.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}})),Ie=Se(((t,i)=>{var s=Te(),e=Re(),n=We(),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})),Be=Se(((t,i)=>{i.exports=function(t){return null==t}})),Ye=Se(((t,i)=>{var s=Be(),e=TypeError;i.exports=function(t){if(s(t))throw new e("Can't call method on "+t);return t}})),He=Se(((t,i)=>{var s=Ie(),e=Ye();i.exports=function(t){return s(e(t))}})),Ve=Se(((t,i)=>{var s=ze();i.exports=function(t){return"object"==typeof t?null!==t:s(t)}})),Xe=Se(((t,i)=>{i.exports={}})),Je=Se(((t,i)=>{var s=Xe(),e=Pe(),n=ze(),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]}})),qe=Se(((t,i)=>{var s=Pe().navigator,e=s&&s.userAgent;i.exports=e?String(e):""})),Ke=Se(((t,i)=>{var s,e,n=Pe(),r=qe(),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})),Qe=Se(((t,i)=>{var s=Ke(),e=Re(),n=Pe().String;i.exports=!!Object.getOwnPropertySymbols&&!e((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))})),Ze=Se(((t,i)=>{var s=Qe();i.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),tn=Se(((t,i)=>{var s=Je(),e=ze(),n=Ee(),r=Ze(),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))}})),sn=Se(((t,i)=>{var s=String;i.exports=function(t){try{return s(t)}catch(t){return"Object"}}})),en=Se(((t,i)=>{var s=ze(),e=sn(),n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not a function")}})),nn=Se(((t,i)=>{var s=en(),e=Be();i.exports=function(t,i){var n=t[i];return e(n)?void 0:s(n)}})),rn=Se(((t,i)=>{var s=Fe(),e=ze(),n=Ve(),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")}})),on=Se(((t,i)=>{i.exports=!0})),hn=Se(((t,i)=>{var s=Pe(),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}})),an=Se(((t,i)=>{var s=on(),e=Pe(),n=hn(),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"})})),ln=Se(((t,i)=>{var s=an();i.exports=function(t,i){return s[t]||(s[t]=i||{})}})),cn=Se(((t,i)=>{var s=Ye(),e=Object;i.exports=function(t){return e(s(t))}})),un=Se(((t,i)=>{var s=Te(),e=cn(),n=s({}.hasOwnProperty);i.exports=Object.hasOwn||function(t,i){return n(e(t),i)}})),dn=Se(((t,i)=>{var s=Te(),e=0,n=Math.random(),r=s(1.1.toString);i.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+r(++e+n,36)}})),fn=Se(((t,i)=>{var s=Pe(),e=ln(),n=un(),r=dn(),o=Qe(),h=Ze(),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]}})),vn=Se(((t,i)=>{var s=Fe(),e=Ve(),n=tn(),r=nn(),o=rn(),h=fn(),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)}})),pn=Se(((t,i)=>{var s=vn(),e=tn();i.exports=function(t){var i=s(t,"string");return e(i)?i:i+""}})),gn=Se(((t,i)=>{var s=Pe(),e=Ve(),n=s.document,r=e(n)&&e(n.createElement);i.exports=function(t){return r?n.createElement(t):{}}})),mn=Se(((t,i)=>{var s=Ue(),e=Re(),n=gn();i.exports=!s&&!e((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))})),bn=Se((t=>{var i=Ue(),s=Fe(),e=Ge(),n=je(),r=He(),o=pn(),h=un(),a=mn(),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])}})),yn=Se(((t,i)=>{var s=Re(),e=ze(),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})),wn=Se(((t,i)=>{var s=De(),e=en(),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)}}})),xn=Se(((t,i)=>{var s=Ue(),e=Re();i.exports=s&&e((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),Sn=Se(((t,i)=>{var s=Ve(),e=String,n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not an object")}})),$n=Se((t=>{var i=Ue(),s=mn(),e=xn(),n=Sn(),r=pn(),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}})),Mn=Se(((t,i)=>{var s=Ue(),e=$n(),n=je();i.exports=s?function(t,i,s){return e.f(t,i,n(1,s))}:function(t,i,s){return t[i]=s,t}})),_n=Se(((t,i)=>{var s=Pe(),e=Ce(),n=De(),r=ze(),o=bn().f,h=yn(),a=Xe(),l=wn(),c=Mn(),u=un();an();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,k=S?a:a[x]||c(a,x,{})[x],O=k.prototype;for(p in i)f=!(e=h(S?p:x+($?".":"#")+p,t.forced))&&_&&u(_,p),m=k[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(k,p,y),M&&(u(a,v=x+"Prototype")||c(a,v,{}),c(a[v],p,g),t.real&&O&&(e||!O[p])&&c(O,p,g)))}})),kn=Se(((t,i)=>{var s=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(t){var i=+t;return(i>0?e:s)(i)}})),On=Se(((t,i)=>{var s=kn();i.exports=function(t){var i=+t;return i!=i||0===i?0:s(i)}})),Nn=Se(((t,i)=>{var s=On(),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)}})),An=Se(((t,i)=>{var s=On(),e=Math.min;i.exports=function(t){var i=s(t);return i>0?e(i,9007199254740991):0}})),Rn=Se(((t,i)=>{var s=An();i.exports=function(t){return s(t.length)}})),Ln=Se(((t,i)=>{var s=He(),e=Nn(),n=Rn(),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)}})),Tn=Se(((t,i)=>{i.exports=function(){}})),En=Se((()=>{var t=_n(),i=Ln().includes,s=Re(),e=Tn(),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")})),Pn=Se(((t,i)=>{var s=Pe(),e=Xe();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]}})),Cn=Se(((t,i)=>{En();var s=Pn();i.exports=s("Array","includes")})),Wn=Se(((t,i)=>{var s=Ve(),e=We(),n=fn()("match");i.exports=function(t){var i;return s(t)&&(void 0!==(i=t[n])?!!i:"RegExp"===e(t))}})),Dn=Se(((t,i)=>{var s=Wn(),e=TypeError;i.exports=function(t){if(s(t))throw new e("The method doesn't accept regular expressions");return t}})),zn=Se(((t,i)=>{var s={};s[fn()("toStringTag")]="z",i.exports="[object z]"===String(s)})),Un=Se(((t,i)=>{var s=zn(),e=ze(),n=We(),r=fn()("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}})),Fn=Se(((t,i)=>{var s=Un(),e=String;i.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return e(t)}})),Gn=Se(((t,i)=>{var s=fn()("match");i.exports=function(t){var i=/./;try{"/./"[t](i)}catch(e){try{return i[s]=!1,"/./"[t](i)}catch(t){}}return!1}})),jn=Se((()=>{var t=_n(),i=Te(),s=Dn(),e=Ye(),n=Fn(),r=Gn(),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)}})})),In=Se(((t,i)=>{jn();var s=Pn();i.exports=s("String","includes")})),Bn=Se(((t,i)=>{var s=Ee(),e=Cn(),n=In(),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}})),Yn=Me(Se(((t,i)=>{var s=Bn();i.exports=s}))());function Hn(t,i){let s;const e=t.length,n=[];for(s=0;s<e;s++)n.push(i(t[s]));return n}function Vn(t){return t%360*Math.PI/180}function Xn(t){return t.replace(/([A-Z])/g,(function(t,i){return"-"+i.toLowerCase()}))}function Jn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qn(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 Kn(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,Yn.default)(e).call(e,"left")?h:(0,Yn.default)(e).call(e,"right")?h+s:h+s/2),o&&(n=(0,Yn.default)(n).call(n,"top")?a:(0,Yn.default)(n).call(n,"bottom")?a+t:a+t/2)}return[e,n]}const Qn=new Set(["desc","metadata","title"]),Zn=t=>Qn.has(t.nodeName),tr="http://www.w3.org/2000/svg",ir="http://www.w3.org/2000/xmlns/",sr="http://www.w3.org/1999/xlink",er={window:"undefined"==typeof window?null:window,document:"undefined"==typeof document?null:document};var nr=class{};const rr={},or="___SYMBOL___ROOT___";function hr(t,i=tr){return er.document.createElementNS(i,t)}function ar(t,i=!1){if(t instanceof nr)return t;if("object"==typeof t)return ur(t);if(null==t)return new rr[or];if("string"==typeof t&&"<"!==t.trim().charAt(0))return ur(er.document.querySelector(t));const s=i?er.document.createElement("div"):hr("svg");return s.innerHTML=t.trim(),t=ur(s.firstElementChild),s.removeChild(s.firstElementChild),t}function lr(t,i){return i&&(i instanceof er.window.Node||i.ownerDocument&&i instanceof i.ownerDocument.defaultView.Node)?i:hr(t)}function cr(t){if(!t)return null;if(t.instance instanceof nr)return t.instance;if("#document-fragment"===t.nodeName)return new rr.Fragment(t);let i=Jn(t.nodeName||"Dom");return"LinearGradient"===i||"RadialGradient"===i?i="Gradient":rr[i]||(i="Dom"),new rr[i](t)}let ur=cr;function dr(t,i=t.name,s=!1){return rr[i]=t,s&&(rr[or]=t),Ae(Object.getOwnPropertyNames(t.prototype)),t}let fr=1e3;function vr(t){return"Svgjs"+Jn(t)+fr++}function pr(t){for(let i=t.children.length-1;i>=0;i--)pr(t.children[i]);return t.id?(t.id=vr(t.nodeName),t):t}function gr(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 mr(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)}}Oe("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=ar(t)).remove();const i=this.position();return this.parent().add(t,i),this},after:function(t){(t=ar(t)).remove();const i=this.position();return this.parent().add(t,i+1),this},insertBefore:function(t){return(t=ar(t)).before(this),this},insertAfter:function(t){return(t=ar(t)).after(this),this}});const br=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,yr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,wr=/rgb\((\d+),(\d+),(\d+)\)/,xr=/^(#[^\s]+)$/,Sr=/\)\s*,?\s*/,$r=/\s/g,Mr=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,_r=/^rgb\(/,kr=/^(\s+)?$/,Or=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Nr=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,Ar=/[\s,]+/,Rr=/[MLHVCSQTAZ]/i;Oe("Dom",{classes:function(){const t=this.attr("class");return null==t?[]:t.trim().split(Ar)},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:Xn(t);function Tr(t){const i=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===i.length?"0"+i:i}function Er(t,i){for(let s=i.length;s--;)if(null==t[i[s]])return!1;return!0}function Pr(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}Oe("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]||kr.test(t[i])?"":t[i])}return 2===arguments.length&&this.node.style.setProperty(Lr(t),null==i||kr.test(i)?"":i),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),Oe("Dom",{data:function(t,i,s){if(null==t)return this.data(Hn(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}}),Oe("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 Cr=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&&(Mr.test(t)||_r.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=Er(t,"rgb")?{_a:t.r,_b:t.g,_c:t.b,_d:0,space:"rgb"}:Er(t,"xyz")?{_a:t.x,_b:t.y,_c:t.z,_d:0,space:"xyz"}:Er(t,"hsl")?{_a:t.h,_b:t.s,_c:t.l,_d:0,space:"hsl"}:Er(t,"lab")?{_a:t.l,_b:t.a,_c:t.b,_d:0,space:"lab"}:Er(t,"lch")?{_a:t.l,_b:t.c,_c:t.h,_d:0,space:"lch"}:Er(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(_r.test(t)){const i=t.replace($r,""),[s,e,n]=wr.exec(i).slice(1,4).map((t=>parseInt(t)));Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}else{if(!Mr.test(t))throw Error("Unsupported string format, can't construct Color");{const i=t=>parseInt(t,16),[,s,e,n]=yr.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*Pr(r,n,i+1/3),h=255*Pr(r,n,i),a=255*Pr(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(Tr);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))))}},Wr=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){zr.isMatrixLike(t)||(t=new zr(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 Dr(t,i){return Math.abs(i-t)<1e-6}var zr=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 Wr(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),u=c.x,d=c.y,f=new Wr(t.position??t.px??t.positionX??NaN,t.py??t.positionY??NaN),v=f.x,p=f.y,g=new Wr(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=g.x,b=g.y,y=new Wr(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 Dr(this.a,s.a)&&Dr(this.b,s.b)&&Dr(this.c,s.c)&&Dr(this.d,s.d)&&Dr(this.e,s.e)&&Dr(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 co?i.matrixify():"string"==typeof i?t.fromArray(i.split(Ar).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=Vn(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=Vn(t),i=Vn(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 Wr(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 Wr(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 Ur(){if(!Ur.nodes||Ur.nodes.svg.node.ownerDocument!==er.document){const t=ar().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"),Ur.nodes={svg:t,path:t.path().node}}return Ur.nodes.svg.node.parentNode||Ur.nodes.svg.addTo(er.document.body||er.document.documentElement),Ur.nodes}function Fr(t){return!(t.width||t.height||t.x||t.y)}dr(zr,"Matrix");var Gr=class t{constructor(...t){this.init(...t)}addOffset(){return this.x+=er.window.pageXOffset,this.y+=er.window.pageYOffset,new t(this)}init(t){return t="string"==typeof t?t.split(Ar).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 Fr(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 zr||(i=new zr(i));let s=1/0,e=-1/0,n=1/0,r=-1/0;return[new Wr(this.x,this.y),new Wr(this.x2,this.y),new Wr(this.x,this.y2),new Wr(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 jr(t,i,s){let e;try{if(e=i(t.node),Fr(e)&&(n=t.node)!==er.document&&!(er.document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===er.document}).call(er.document.documentElement,n))throw new Error("Element not in the dom")}catch(i){e=s(t)}var n;return e}Oe({viewbox:{viewbox(t,i,s,e){return null==t?new Gr(this.attr("viewBox")):this.attr("viewBox",new Gr(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 Wr(s/2/r+n.x,e/2/o+n.y);const l=new Gr(n).transform(new zr({scale:a,origin:i}));return this.viewbox(l)}}}),dr(Gr,"Box");var Ir=class extends Array{constructor(t=[],...i){if(super(t,...i),"number"==typeof t)return this;this.length=0,this.push(...t)}};gr([Ir],{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 Br=["toArray","constructor","each"];function Yr(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(xr);return e?e[1].slice(1):null}function Hr(t,i){const s=`#${er.window.CSS.escape(i)}`;return 1===t.nodeType&&t.matches(s)?t:t.querySelector(s)}function Vr(t,i,s=`[${i}]`){const e=t.getAttribute("id"),n=t.getRootNode();if(!e||Hr(n,e)!==t)return new Ir;const r=[];1===n.nodeType&&n.matches(s)&&Yr(n.getAttribute(i))===e&&r.push(cr(n));for(const t of n.querySelectorAll(s))Yr(t.getAttribute(i))===e&&r.push(cr(t));return new Ir(r)}Ir.extend=function(t){t=t.reduce(((t,i)=>((0,Yn.default)(Br).call(Br,i)||"_"===i[0]||(i in Array.prototype&&(t["$"+i]=Array.prototype[i]),t[i]=function(...t){return this.each(i,...t)}),t)),{}),gr([Ir],t)};let Xr=0;const Jr=new WeakMap,qr=new WeakMap,Kr=()=>Object.create(null);function Qr(t){const i=t.getEventHolder();let s=Jr.get(i);return s||(s=Kr(),Jr.set(i,s)),s}function Zr(t){return t.getEventTarget()}function to(t,i,s,e,n){const r=s.bind(e||t),o=n||!1,h=ar(t),a=Qr(h),l=Zr(h);i=Array.isArray(i)?i:i.split(Ar);let c=qr.get(s);c||(c=++Xr,qr.set(s,c)),i.forEach((function(t){const i=t.split(".")[0],s=t.split(".")[1]||"*";a[i]=a[i]||Kr(),a[i][s]=a[i][s]||Kr(),a[i][s][c]=a[i][s][c]||[],a[i][s][c].push({listener:r,options:o}),l.addEventListener(i,r,o)}))}function io(t,i,s,e){const n=ar(t),r=Qr(n),o=Zr(n);("function"!=typeof s||(s=qr.get(s)))&&(i=Array.isArray(i)?i:(i||"").split(Ar)).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])io(o,[i,h].join("."),l);delete r[i][h]}}else if(h)for(t in r)for(a in r[t])h===a&&io(o,[t,h].join("."));else if(i){if(r[i]){for(a in r[i])io(o,[i,a].join("."));delete r[i]}}else{for(t in r)io(o,t);!function(t){Jr.delete(t.getEventHolder())}(n)}}))}var so=class extends nr{addEventListener(){}dispatch(t,i,s){return function(t,i,s,e){const n=Zr(t);return i instanceof er.window.Event||(i=new er.window.CustomEvent(i,{detail:s,cancelable:!0,...e})),n.dispatchEvent(i),i}(this,t,i,s)}dispatchEvent(t){const i=Qr(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 io(this,t,i,s),this}on(t,i,s,e){return to(this,t,i,s,e),this}removeEventListener(){}};function eo(){}dr(so,"EventTarget");const no={"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 ro=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(Ar).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}},oo=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(br))&&(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 ho=new Set(["fill","stroke","color","bgcolor","stop-color","flood-color","lighting-color"]),ao=[];var lo=class t extends so{constructor(t,i){super(),this.node=t,this.type=t.nodeName,i&&t!==i&&this.attr(i)}add(t,i){return(t=ar(t)).removeNamespace&&this.node instanceof er.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 ar(t).put(this,i)}children(){return new Ir(Hn(this.node.children,(function(t){return cr(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=pr(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(hr(i),s))}first(){return cr(this.node.firstChild)}get(t){return cr(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=vr(this.type)),this.attr("id",t)}index(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}last(){return cr(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=cr(i.node.parentNode),!t)return i;do{if("string"==typeof t?i.matches(t):i instanceof t)return i}while(i=cr(i.node.parentNode));return i}put(t,i){return t=ar(t),this.add(t,i),t}putIn(t,i){return ar(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=ar(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,tr)}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=cr(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=hr("wrapper",s),n=er.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)}};gr(lo,{attr:function(t,i,s){if(null==t){t={},i=this.node.attributes;for(const s of i)t[s.nodeName]=Or.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))?no[t]:Or.test(i)?parseFloat(i):i;"number"==typeof(i=ao.reduce(((i,s)=>s(t,i,this)),i))?i=new oo(i):ho.has(t)&&Cr.isColor(i)?i=new Cr(i):i.constructor===Array&&(i=new ro(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 Ir(Hn((i||er.document).querySelectorAll(t),(function(t){return cr(t)})))}(t,this.node)},findOne:function(t){return cr(this.node.querySelector(t))}}),dr(lo,"Dom");var co=class extends lo{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 oo(t).plus(this.x()))}dy(t=0){return this.y(new oo(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&&ar(t).node);const n=new Ir;let r=this;for(;(r=r.parent())&&r.node!==er.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=Yr(i);return s?Hr(t.getRootNode(),s):null}(this.node,t);return i?ar(i):null}root(){const t=this.parent(rr[or]);return t&&t.root()}setData(t){return this.dom=t,this}size(t,i){const s=qn(this,t,i);return this.width(new oo(s.width)).height(new oo(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)}};gr(co,{bbox:function(){const t=jr(this,(t=>t.getBBox()),(t=>{try{const i=t.clone().addTo(Ur().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 Gr(t)},rbox:function(t){const i=jr(this,(t=>t.getBoundingClientRect()),(t=>{throw new Error(`Getting rbox of element "${t.node.nodeName}" is not possible`)})),s=new Gr(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 Wr(t,i).transformO(this.screenCTM().inverseO())},ctm:function(){return new zr(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 zr(i)}return new zr(this.node.getScreenCTM())}catch(t){return console.warn(`Cannot get CTM from SVG node ${this.node.nodeName}. Is the element rendered?`),new zr}}}),dr(co,"Element");const uo={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 Cr||Cr.isRgb(i)||i instanceof co)this.attr(t,i);else for(s=uo[t].length-1;s>=0;s--)null!=i[uo[t][s]]&&this.attr(uo.prefix(t,uo[t][s]),i[uo[t][s]]);return this},Oe(["Element","Runner"],i)})),Oe(["Element","Runner"],{matrix:function(t,i,s,e,n,r){return null==t?new zr(this):this.attr("transform",new zr(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)}}),Oe("radius",{radius:function(t,i=t){return"radialGradient"===(this._element||this).type?this.attr("r",new oo(t)):this.rx(t).ry(i)}}),Oe("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new Wr(this.node.getPointAtLength(t))}}),Oe(["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)}}),Oe("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}),{})),Oe("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(Sr).slice(0,-1).map((function(t){const i=t.trim().split("(");return[i[0].trim(),i[1].split(Ar).map((function(t){return parseFloat(t)}))]})).reverse().reduce((function(t,i){return"matrix"===i[0]?t.lmultiply(zr.fromArray(i[1])):t[i[0]].apply(t,i[1])}),new zr)},toParent:function(t,i){if(this===t)return this;if(Zn(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 zr(this).decompose();return null==t?i:i[t]}zr.isMatrixLike(t)||(t={...t,origin:Kn(t,this)});const s=new zr(!0===i?this:i||!1).transform(t);return this.attr("transform",s)}});var fo=class t extends co{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()}};dr(fo,"Container");var vo=class extends fo{constructor(t,i=t){super(lr("defs",t),i)}flatten(){return this}ungroup(){return this}};dr(vo,"Defs");var po=class extends co{};dr(po,"Shape");var go=$e({cx:()=>xo,cy:()=>So,height:()=>Mo,rx:()=>mo,ry:()=>bo,width:()=>$o,x:()=>yo,y:()=>wo});function mo(t){return this.attr("rx",t)}function bo(t){return this.attr("ry",t)}function yo(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function wo(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function xo(t){return this.attr("cx",t)}function So(t){return this.attr("cy",t)}function $o(t){return null==t?2*this.rx():this.rx(new oo(t).divide(2))}function Mo(t){return null==t?2*this.ry():this.ry(new oo(t).divide(2))}var _o=class extends po{constructor(t,i=t){super(lr("ellipse",t),i)}size(t,i){const s=qn(this,t,i);return this.rx(new oo(s.width).divide(2)).ry(new oo(s.height).divide(2))}};gr(_o,go),Oe("Container",{ellipse:mr((function(t=0,i=t){return this.put(new _o).size(t,i).move(0,0)}))}),dr(_o,"Ellipse");var ko=class extends lo{constructor(t=er.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 lo(hr("wrapper",s));return t.add(this.node.cloneNode(!0)),t.xml(!1,s)}return super.xml(t,!1,s)}};dr(ko,"Fragment");var Oo=$e({from:()=>No,to:()=>Ao});function No(t,i){return this.attr("radialGradient"===(this._element||this).type?{fx:new oo(t),fy:new oo(i)}:{x1:new oo(t),y1:new oo(i)})}function Ao(t,i){return this.attr("radialGradient"===(this._element||this).type?{cx:new oo(t),cy:new oo(i)}:{x2:new oo(t),y2:new oo(i)})}var Ro=class extends fo{constructor(t,i){super(lr(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 Gr}targets(){return Vr(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()+")"}};gr(Ro,Oo),Oe({Container:{gradient(...t){return this.defs().gradient(...t)}},Defs:{gradient:mr((function(t,i){return this.put(new Ro(t)).update(i)}))}}),dr(Ro,"Gradient");var Lo=class extends fo{constructor(t,i=t){super(lr("pattern",t),i)}attr(t,i,s){return"transform"===t&&(t="patternTransform"),super.attr(t,i,s)}bbox(){return new Gr}targets(){return Vr(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()+")"}};Oe({Container:{pattern(...t){return this.defs().pattern(...t)}},Defs:{pattern:mr((function(t,i,s){return this.put(new Lo).update(s).attr({x:0,y:0,width:t,height:i,patternUnits:"userSpaceOnUse"})}))}}),dr(Lo,"Pattern");var To=class extends po{constructor(t,i=t){super(lr("image",t),i)}load(t,i){if(!t)return this;const s=new er.window.Image;return to(s,"load",(function(t){const e=this.parent(Lo);0===this.width()&&0===this.height()&&this.size(s.width,s.height),e instanceof Lo&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,t)}),this),to(s,"load error",(function(){io(s)})),this.attr("href",s.src=t,sr)}};ao.push((function(t,i,s){return"fill"!==t&&"stroke"!==t||Nr.test(i)&&(i=s.root().defs().image(i)),i instanceof To&&(i=s.root().defs().pattern(0,0,(t=>{t.add(i)}))),i})),Oe({Container:{image:mr((function(t,i){return this.put(new To).size(0,0).load(t,i)}))}}),dr(To,"Image");var Eo=class extends ro{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 Gr(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(Ar).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){zr.isMatrixLike(t)||(t=new zr(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}},Po=$e({MorphArray:()=>Co,height:()=>Uo,width:()=>zo,x:()=>Wo,y:()=>Do});const Co=Eo;function Wo(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}function Do(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}function zo(t){const i=this.bbox();return null==t?i.width:this.size(t,i.height)}function Uo(t){const i=this.bbox();return null==t?i.height:this.size(i.width,t)}var Fo=class extends po{constructor(t,i=t){super(lr("line",t),i)}array(){return new Eo([[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 Eo(t).toLine(),this.attr(t))}size(t,i){const s=qn(this,t,i);return this.attr(this.array().size(s.width,s.height).toLine())}};gr(Fo,Po),Oe({Container:{line:mr((function(...t){return Fo.prototype.plot.apply(this.put(new Fo),null!=t[0]?t:[0,0,0,0])}))}}),dr(Fo,"Line");var Go=class extends fo{constructor(t,i=t){super(lr("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 jo(t,i){return function(s){return null==s?this[t]:(this[t]=s,i&&i.call(this),this)}}Oe({Container:{marker(...t){return this.defs().marker(...t)}},Defs:{marker:mr((function(t,i,s){return this.put(new Go).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 Go?arguments[1]:this.defs().marker(i,s,e),this.attr(n,t)}}}),dr(Go,"Marker");const Io={"-":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 Bo=class{done(){return!1}},Yo=class extends Bo{constructor(t=">"){super(),this.ease=Io[t]||t}step(t,i,s){return"number"!=typeof t?s<1?t:i:t+(i-t)*this.ease(s)}},Ho=class extends Bo{constructor(t){super(),this.stepper=t}done(t){return t.done}step(t,i,s,e){return this.stepper(t,i,s,e)}};function Vo(){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}gr(class extends Ho{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:jo("_duration",Vo),overshoot:jo("_overshoot",Vo)}),gr(class extends Ho{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:jo("_windup"),p:jo("P"),i:jo("I"),d:jo("D")});const Xo={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},Jo={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]]}},qo="mlhvqtcsaz".split("");for(let t=0,i=qo.length;t<i;++t)Jo[qo[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 Jo[t](i,s,e)}}(qo[t].toUpperCase());function Ko(t){return t.segment.length&&t.segment.length-1===Xo[t.segment[0].toUpperCase()]}function Qo(t,i){t.inNumber&&Zo(t,!1);const s=Rr.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 Zo(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,Ko(t)&&th(t)}function th(t){t.inSegment=!1,t.absolute&&(t.segment=function(t){return Jo[t.segment[0]](t.segment.slice(1),t.p,t.p0)}(t)),t.segments.push(t.segment)}function ih(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 sh(t){return"E"===t.lastToken.toUpperCase()}const eh=new Set([" ",",","\t","\n","\r","\f"]);var nh=class extends ro{bbox(){return Ur().path.setAttribute("d",this.toString()),new Gr(Ur.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 Wr,p:new Wr};for(;n.lastToken=e,e=t.charAt(s++);)if(n.inSegment||!Qo(n,e))if("."!==e)if(isNaN(parseInt(e)))if(eh.has(e))n.inNumber&&Zo(n,!1);else if("-"!==e&&"+"!==e)if("E"!==e.toUpperCase()){if(Rr.test(e)){if(n.inNumber)Zo(n,!1);else{if(!Ko(n))throw new Error("parser Error");th(n)}--s}}else n.number+=e,n.hasExponent=!0;else{if(n.inNumber&&!sh(n)){Zo(n,!1),--s;continue}n.number+=e,n.inNumber=!0}else{if("0"===n.number||ih(n)){n.inNumber=!0,n.number=e,Zo(n,!0);continue}n.inNumber=!0,n.number+=e}else{if(n.pointSeen||n.hasExponent){Zo(n,!1),--s;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=e}return n.inNumber&&Zo(n,!1),n.inSegment&&Ko(n)&&th(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 rh=t=>{const i=typeof t;return"number"===i?oo:"string"===i?Cr.isColor(t)?Cr:Ar.test(t)?Rr.test(t)?nh:ro:br.test(t)?oo:hh:uh.indexOf(t.constructor)>-1?t.constructor:Array.isArray(t)?ro:"object"===i?ch:hh};var oh=class{constructor(t){this._stepper=t||new Yo("-"),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(rh(t));let i=new this._type(t);return this._type===Cr&&(i=this._to?i[this._to[4]]():this._from?i[this._from[4]]():i),this._type===ch&&(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}},hh=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}},ah=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]}};ah.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};const lh=(t,i)=>t[0]<i[0]?-1:t[0]>i[0]?1:0;var ch=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]===Cr&&t[s+7]!==i[s+7]){const i=t[s+7],e=new Cr(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=rh(t[s]),n=new e(t[s]).toArray();i.push([s,e,n.length,...n])}return i.sort(lh),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 uh=[hh,ah,ch];var dh=class extends po{constructor(t,i=t){super(lr("path",t),i)}array(){return this._array||(this._array=new nh(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 nh(t))}size(t,i){const s=qn(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)}};dh.prototype.MorphArray=nh,Oe({Container:{path:mr((function(t){return this.put(new dh).plot(t||new nh)}))}}),dr(dh,"Path");var fh=$e({array:()=>vh,clear:()=>ph,move:()=>gh,plot:()=>mh,size:()=>bh});function vh(){return this._array||(this._array=new Eo(this.attr("points")))}function ph(){return delete this._array,this}function gh(t,i){return this.attr("points",this.array().move(t,i))}function mh(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new Eo(t))}function bh(t,i){const s=qn(this,t,i);return this.attr("points",this.array().size(s.width,s.height))}var yh=class extends po{constructor(t,i=t){super(lr("polygon",t),i)}};Oe({Container:{polygon:mr((function(t){return this.put(new yh).plot(t||new Eo)}))}}),gr(yh,Po),gr(yh,fh),dr(yh,"Polygon");var wh=class extends po{constructor(t,i=t){super(lr("polyline",t),i)}};Oe({Container:{polyline:mr((function(t){return this.put(new wh).plot(t||new Eo)}))}}),gr(wh,Po),gr(wh,fh),dr(wh,"Polyline");var xh=class extends po{constructor(t,i=t){super(lr("rect",t),i)}};gr(xh,{rx:mo,ry:bo}),Oe({Container:{rect:mr((function(t,i){return this.put(new xh).size(t,i)}))}}),dr(xh,"Rect");var Sh=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 $h={nextDraw:null,frames:new Sh,timeouts:new Sh,immediates:new Sh,timer:()=>er.window.performance||er.window.Date,transforms:[],frame(t){const i=$h.frames.push({run:t});return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),i},timeout(t,i){i=i||0;const s=$h.timer().now()+i,e=$h.timeouts.push({run:t,time:s});return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),e},immediate(t){const i=$h.immediates.push(t);return null===$h.nextDraw&&($h.nextDraw=er.window.requestAnimationFrame($h._draw)),i},cancelFrame(t){null!=t&&$h.frames.remove(t)},clearTimeout(t){null!=t&&$h.timeouts.remove(t)},cancelImmediate(t){null!=t&&$h.immediates.remove(t)},_draw(t){try{let i=null;const s=$h.timeouts.last();for(;(i=$h.timeouts.shift())&&(t>=i.time?i.run():$h.timeouts.push(i),i!==s););let e=null;const n=$h.frames.last();for(;e!==n&&(e=$h.frames.shift());)e.run(t);let r=null;for(;r=$h.immediates.shift();)r()}finally{const t=$h.timeouts.first()||$h.frames.first()||$h.immediates.first();$h.nextDraw=t?er.window.requestAnimationFrame($h._draw):null}}},Mh=function(t){const i=t.start,s=t.runner.duration();return{start:i,duration:s,end:i+s,runner:t.runner}},_h=function(){const t=er.window;return(t.performance||t.Date).now()};var kh=class extends so{constructor(t=_h){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(Mh);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 $h.cancelFrame(this._nextFrame),this._nextFrame=null,t?this._stepImmediate():(this._paused||(this._nextFrame=$h.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)}};Oe({Element:{timeline:function(t){return null==t?(this._timeline=this._timeline||new kh,this._timeline):(this._timeline=t,this)}}});var Oh=class t extends so{constructor(i){super(),this.id=t.id++,i="function"==typeof(i=null==i?400:i)?new Ho(i):i,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof i&&i,this._isDeclarative=i instanceof Ho,this._stepper=this._isDeclarative?i:new Yo,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new zr,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 Bo||(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 zr,this}clearTransformsFromQueue(){var t;this.done&&this._timeline&&(0,Yn.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 Yo(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||eo,runner:i||eo,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 kh||(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 zr,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}};Oh.id=0;var Nh=class{constructor(t=new zr,i=-1,s=!0){this.transforms=t,this.id=i,this.done=s}clearTransformsFromQueue(){}};gr([Oh,Nh],{mergeWith(t){return new Nh(t.transforms.lmultiply(this.transforms),t.id)}});const Ah=(t,i)=>t.lmultiplyO(i),Rh=t=>t.transforms;function Lh(){const t=this._transformationRunners.runners.map(Rh).reduce(Ah,new zr);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}var Th=class{constructor(){this.runners=[],this.ids=[]}add(t){var i;if((0,Yn.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 Nh).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,Yn.default)(i=n._timeline._runnerIds).call(i,n.id)||t._timeline&&(0,Yn.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}};Oe({Element:{animate(t,i,s){const e=Oh.sanitise(t,i,s),n=this.timeline();return new Oh(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(Rh).reduce(Ah,new zr)},_addRunner(t){this._transformationRunners.add(t),$h.cancelImmediate(this._frameId),this._frameId=$h.immediate(Lh.bind(this))},_prepareRunner(){null==this._frameId&&(this._transformationRunners=(new Th).add(new Nh(new zr(this))))}}}),gr(Oh,{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 oh(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,Yn.default)(n).call(n,t))));var e,n;if(s.length&&null!=r.from()){const i=this.element()[t](s),e=new ch(r.from()).valueOf();Object.assign(e,i),r.from(e)}const h=new ch(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 oh(this._stepper).to(new oo(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=zr.isMatrixLike(t);s=null!=t.affine?t.affine:null!=s?s:!e;const n=new oh(this._stepper).type(s?ah:zr);let r,o,h,a,l;return this.queue((function(){o=o||this.element(),r=r||Kn(t,o),l=new zr(i?void 0:o),o._addRunner(this),i||o._clearTransformRunnersBefore(this)}),(function(c){i||this.clearTransform();const{x:u,y:d}=new Wr(r).transform(o._currentTransform(this)),f={...t,origin:[u,d]};!0===f.relative&&delete f.relative;let v=new zr(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 zr(g),this.addTransform(h),o._addRunner(this),n.done()}),(function(i){(i.origin||"center").toString()!==(t.origin||"center").toString()&&(r=Kn(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 oo(i),this._tryRetarget(t,i))return this;const s=new oh(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 oo(t))})),this._rememberMorpher(t,s),this},_queueObject(t,i){if(this._tryRetarget(t,i))return this;const s=new oh(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 oo(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=qn(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 oh(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 Gr(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)}}),gr(Oh,{rx:mo,ry:bo,from:No,to:Ao}),dr(Oh,"Runner");var Eh=class extends fo{constructor(t,i=t){super(lr("svg",t),i),this.namespace()}defs(){return this.isRoot()?cr(this.node.querySelector("defs"))||this.put(new vo):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof er.window.SVGElement)&&"#document-fragment"!==this.node.parentNode.nodeName}namespace(){return this.isRoot()?this.attr({xmlns:tr,version:"1.1"}).attr("xmlns:xlink",sr,ir):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,ir).attr("xmlns:svgjs",null,ir)}root(){return this.isRoot()?this:super.root()}};Oe({Container:{nested:mr((function(){return this.put(new Eh)}))}}),dr(Eh,"Svg",!0);var Ph=class extends fo{constructor(t,i=t){super(lr("symbol",t),i)}};Oe({Container:{symbol:mr((function(){return this.put(new Ph)}))}}),dr(Ph,"Symbol");var Ch=$e({amove:()=>Hh,ax:()=>Bh,ay:()=>Yh,build:()=>Vh,center:()=>Ih,cx:()=>Gh,cy:()=>jh,length:()=>Dh,move:()=>Fh,plain:()=>Wh,x:()=>zh,y:()=>Uh});function Wh(t){return!1===this._build&&this.clear(),this.node.appendChild(er.document.createTextNode(t)),this}function Dh(){return this.node.getComputedTextLength()}function zh(t,i=this.bbox()){return null==t?i.x:this.attr("x",this.attr("x")+t-i.x)}function Uh(t,i=this.bbox()){return null==t?i.y:this.attr("y",this.attr("y")+t-i.y)}function Fh(t,i,s=this.bbox()){return this.x(t,s).y(i,s)}function Gh(t,i=this.bbox()){return null==t?i.cx:this.attr("x",this.attr("x")+t-i.cx)}function jh(t,i=this.bbox()){return null==t?i.cy:this.attr("y",this.attr("y")+t-i.cy)}function Ih(t,i,s=this.bbox()){return this.cx(t,s).cy(i,s)}function Bh(t){return this.attr("x",t)}function Yh(t){return this.attr("y",t)}function Hh(t,i){return this.ax(t).ay(i)}function Vh(t){return this._build=!!t,this}var Xh=class extends po{constructor(t,i=t){super(lr("text",t),i),this.dom.leading=this.dom.leading??new oo(1.3),this._rebuild=!0,this._build=!1}leading(t){return null==t?this.dom.leading:(this.dom.leading=new oo(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(Zn(this.node))return;const n=er.window.getComputedStyle(this.node).getPropertyValue("font-size"),r=s*new oo(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 oo(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||Zn(i[e])?0===e&&(s=e+1):(e!==s&&3!==i[e].nodeType&&!0===cr(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()}};gr(Xh,Ch),Oe({Container:{text:mr((function(t=""){return this.put(new Xh).text(t)})),plain:mr((function(t=""){return this.put(new Xh).plain(t)}))}}),dr(Xh,"Text");var Jh=class extends po{constructor(t,i=t){super(lr("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 Xh))return this;const i=t.index(this),s=er.window.getComputedStyle(this.node).getPropertyValue("font-size"),e=t.dom.leading*new oo(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)}};gr(Jh,Ch),Oe({Tspan:{tspan:mr((function(t=""){const i=new Jh;return this._build||this.clear(),this.put(i).text(t)}))},Text:{newLine:function(t=""){return this.tspan(t).newLine()}}}),dr(Jh,"Tspan");var qh=class extends po{constructor(t,i=t){super(lr("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 oo(t).divide(2))}};gr(qh,{x:yo,y:wo,cx:xo,cy:So,width:$o,height:Mo}),Oe({Container:{circle:mr((function(t=0){return this.put(new qh).size(t).move(0,0)}))}}),dr(qh,"Circle");var Kh=class extends fo{constructor(t,i=t){super(lr("clipPath",t),i)}remove(){return this.targets().forEach((function(t){t.unclip()})),super.remove()}targets(){return Vr(this.node,"clip-path")}};Oe({Container:{clip:mr((function(){return this.defs().put(new Kh)}))},Element:{clipper(){return this.reference("clip-path")},clipWith(t){const i=t instanceof Kh?t:this.parent().clip().add(t);return this.attr("clip-path","url(#"+i.id()+")")},unclip(){return this.attr("clip-path",null)}}}),dr(Kh,"ClipPath");var Qh=class extends co{constructor(t,i=t){super(lr("foreignObject",t),i)}};Oe({Container:{foreignObject:mr((function(t,i){return this.put(new Qh).size(t,i)}))}}),dr(Qh,"ForeignObject");var Zh=$e({dmove:()=>ta,dx:()=>ia,dy:()=>sa,height:()=>ea,move:()=>na,size:()=>ra,width:()=>oa,x:()=>ha,y:()=>aa});function ta(t,i){return this.children().forEach((s=>{let e;try{e=s.node instanceof er.window.SVGSVGElement?new Gr(s.attr(["x","y","width","height"])):s.bbox()}catch(t){return}const n=new zr(s),r=n.translate(t,i).transform(n.inverse()),o=new Wr(e.x,e.y).transform(r);s.dmove(o.x-e.x,o.y-e.y)})),this}function ia(t){return this.dmove(t,0)}function sa(t){return this.dmove(0,t)}function ea(t,i=this.bbox()){return null==t?i.height:this.size(i.width,t,i)}function na(t=0,i=0,s=this.bbox()){return this.dmove(t-s.x,i-s.y)}function ra(t,i,s=this.bbox()){const e=qn(this,t,i,s),n=e.width/s.width,r=e.height/s.height;return this.children().forEach((t=>{const i=new Wr(s).transform(new zr(t).inverse());t.scale(n,r,i.x,i.y)})),this}function oa(t,i=this.bbox()){return null==t?i.width:this.size(t,i.height,i)}function ha(t,i=this.bbox()){return null==t?i.x:this.move(t,i.y,i)}function aa(t,i=this.bbox()){return null==t?i.y:this.move(i.x,t,i)}var la=class extends fo{constructor(t,i=t){super(lr("g",t),i)}};gr(la,Zh),Oe({Container:{group:mr((function(){return this.put(new la)}))}}),dr(la,"G");var ca=class extends fo{constructor(t,i=t){super(lr("a",t),i)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,sr)}};gr(ca,Zh),Oe({Container:{link:mr((function(t){return this.put(new ca).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 ca,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}}}),dr(ca,"A");var ua=class extends fo{constructor(t,i=t){super(lr("mask",t),i)}remove(){return this.targets().forEach((function(t){t.unmask()})),super.remove()}targets(){return Vr(this.node,"mask")}};Oe({Container:{mask:mr((function(){return this.defs().put(new ua)}))},Element:{masker(){return this.reference("mask")},maskWith(t){const i=t instanceof ua?t:this.parent().mask().add(t);return this.attr("mask","url(#"+i.id()+")")},unmask(){return this.attr("mask",null)}}}),dr(ua,"Mask");var da=class extends co{constructor(t,i=t){super(lr("stop",t),i)}update(t){return("number"==typeof t||t instanceof oo)&&(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 oo(t.offset)),this}};Oe({Gradient:{stop:function(t,i,s){return this.put(new da).update(t,i,s)}}}),dr(da,"Stop");var fa=class extends co{constructor(t,i=t){super(lr("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+=Xn(t)+":"+i[t]+";";return s+="}",s}(t,i))}};Oe("Dom",{style(t,i){return this.put(new fa).rule(t,i)},fontface(t,i,s){return this.put(new fa).font(t,i,s)}}),dr(fa,"Style");var va=class extends Xh{constructor(t,i=t){super(lr("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")}};Oe({Container:{textPath:mr((function(t,i){return t instanceof Xh||(t=this.text(t)),t.path(i)}))},Text:{path:mr((function(t,i=!0){const s=new va;let e;if(t instanceof dh||(t=this.defs().path(t)),s.attr("href","#"+t,sr),i)for(;e=this.node.firstChild;)s.node.appendChild(e);return this.put(s)})),textPath(){return this.findOne("textPath")}},Path:{text:mr((function(t){return t instanceof Xh||(t=(new Xh).addTo(this.parent()).text(t)),t.path(this)})),targets(){return Vr(this.node,"href","textPath")}}}),va.prototype.MorphArray=nh,dr(va,"TextPath");var pa=class extends po{constructor(t,i=t){super(lr("use",t),i)}use(t,i){return this.attr("href",(i||"")+"#"+t,sr)}};function ga(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}Oe({Container:{use:mr((function(t,i){return this.put(new pa).use(t,i)}))}}),dr(pa,"Use"),gr([Eh,Ph,To,Lo,Go],Ne("viewbox")),gr([Fo,wh,yh,dh],Ne("marker")),gr(Xh,Ne("Text")),gr(dh,Ne("Path")),gr(vo,Ne("Defs")),gr([Xh,Jh],Ne("Tspan")),gr([xh,_o,Ro,Oh],Ne("radius")),gr(so,Ne("EventTarget")),gr(lo,Ne("Dom")),gr(co,Ne("Element")),gr(po,Ne("Shape")),gr([fo,ko],Ne("Container")),gr(Ro,Ne("Gradient")),gr(Oh,Ne("Runner")),Ir.extend([...new Set(ke)]),function(t=[]){uh.push(...[].concat(t))}([oo,Cr,Gr,zr,ro,Eo,nh,Wr]),gr(uh,{to(t){return(new oh).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 ma,ba={},ya=function(){if(ma)return ba;ma=1;var t={};return Object.defineProperty(ba,"__esModule",{value:!0}),ba.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},ba}(),wa=y(ya);const xa=["pl","fc","pp","ac"];function Sa(t){return t.replace(/\d+$/,"")}function $a(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 Ma{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 _a,ka;!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"}(_a||(_a={}));class Oa{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=t=>null===this.groupSeparator?h.format(t):h.formatToParts(t).map((t=>"group"===t.type?this.groupSeparator:t.value)).join(""),l=a(t/n);return(l===a(-0)?a(0):l).replace(/\s+(%)/g,"$1")}static translateScenarioLabel(t,i){if(null==t)return"";const s=new Xs(t);if(!s.isValid)return`${i.get(t)||t}`;let e,n;return _a.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 wa(t.map((t=>Oa.translateScenarioLabel(t,i))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:s.fontStyles.font,fontSize:s.fontStyles.size+"px"}).width}}Oa.formats=new Map,Oa.groupSeparator=null;class Na{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=Na.niceStep(i,t),e=Math.ceil(this.domainMin/s)*s;if(e+s===e||s<Math.pow(10,-15))return[this.domainMin];const n=Na.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:Na.stepDecimals(1===t.length?Math.abs(t[0]):(t[t.length-1]-t[0])/(t.length-1))}}function Aa(t,i,s,e=!1){return Oa.number(t,e?"percent":"decimal",i,i,1,s)}function Ra(t,i){return Na.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"}(ka||(ka={}));let Ta=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||ka.Top,this.horizontalHookLocation=h||ka.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");const a=this.isRelativeLabel&&this.isVarianceLabel&&!1===i.percentSign,l=i=>a?Oa.number(Number((100*i).toPrecision(15)),"decimal",e,o,1,this.styles.locale):Oa.number(i,t,e,o,h,this.styles.locale);n=l(Number(this.value));const c=l(0);this.isVarianceLabel&&Number(this.value)>0&&n!==c&&(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(as(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(as(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===ka.Left?(e="left",a=n.x()):this.horizontalHookLocation===ka.Center?(e="middle",a=n.x()-(o+2)/2):this.horizontalHookLocation===ka.Right&&(e="end",a=n.x()-o),this.verticalHookLocation===ka.Center?(u=n.y()-1.2*h/2,l=u+.2*h):this.verticalHookLocation===ka.Top?(u-=h/4,l=u+.2*h):this.verticalHookLocation===ka.Bottom&&(u-=h,l=u+.2*h),n.move(c,u),n.font({anchor:e}),null!=this.segmentFillColor?n.fill($a(this.segmentFillColor)):t.rect(o+2,.8*h).stroke(s).fill(s).opacity(.9).move(this.horizontalHookLocation===ka.Center?a:a-1,l).insertBefore(n),n}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}};const Ea={ac:1,pp:2,fc:3,pl:4};var Pa;!function(t){t[t.Above=0]="Above",t[t.Below=1]="Below",t[t.Left=2]="Left",t[t.Right=3]="Right"}(Pa||(Pa={}));class Ca{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=Ea[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 Pa.Above:a=t,l=i-r-o,c=ka.Bottom,u=ka.Center,d=t-s/2,f=i-r-o-e;break;case Pa.Below:a=t,l=i+r+o,c=ka.Top,u=ka.Center,d=t-s/2,f=i+r+o-e/4;break;case Pa.Left:a=t-r-o,l=i,c=ka.Center,u=ka.Right,d=t-r-o-s,f=i-.6*e;break;case Pa.Right:a=t+r+o,l=i,c=ka.Center,u=ka.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&&((Ea[s.scenarioType]||99)<i&&this.intersects(t,s))))}shouldHideScenarioLabel(t,i,s,e=20){const n=Ea[s]||99;return!(n<=1)&&this.scenarioLabels.some((s=>{if((Ea[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 Wa=["n","ne","e","se","s","sw","w","nw"],Da=Math.SQRT1_2;class za{constructor(t,i,s=new Ca){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 Wa){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*Da+.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:ka.Center}}}class Ua{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 Ua("local",t,i,s,0)}static grouped(t){return new Ua("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 Fa{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:si(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:si(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:si(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(ss,"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(Aa(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(Aa(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 Ga{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=wa(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 ja{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 Ia=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class Ba{adapt(t){const i=new ja;if(R.isOperator(t.operation)&&(i.operation=t.operation),R.isString(t.date)){const s=w.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 Ia){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 ja}}const Ya={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function Ha(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 Va(t,i){return void 0!==i&&(void 0!==i.min&&t<i.min||void 0!==i.max&&t>i.max)}function Xa(t,i){return"scenario"!==t.kind?null:i+D(t.slot)}function Ja(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?Xa(i.measures.x,S):null,M=null!==S?Xa(i.measures.y,S):null,_=null!==S&&void 0!==i.measures.size?Xa(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:"",k=`${u}\0${S}\0${t}`;if(d.has(k)){v++,f.length<5&&!f.includes(t)&&f.push(t);continue}const O=Ha(s,i.measures.x),N=Ha(s,i.measures.y);if(null===O.value||null===N.value){(O.varianceNoData||N.varianceNoData)&&p++;continue}if(Va(O.value,null===(r=i.domains)||void 0===r?void 0:r.x)||Va(N.value,null===(o=i.domains)||void 0===o?void 0:o.y)){g++;continue}const A={name:t,seriesKey:S,facetKey:u,x:O.value,y:N.value,row:s};if(void 0!==i.measures.size){const t=Ha(s,i.measures.size).value;if(null===t)continue;if(t<0){m++;continue}A.size=t}if(void 0!==i.measures.share){const t=Ha(s,i.measures.share).value;null!==t&&(t<0||t>1?(b++,A.share=Math.min(1,Math.max(0,t))):A.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?A.compare=null:Va(t,null===(h=i.domains)||void 0===h?void 0:h.x)||Va(e,null===(a=i.domains)||void 0===a?void 0:a.y)?(g++,A.compare=null):(A.compare={x:t,y:e},null!==n&&(A.compare.size=n))}if(d.add(k),x.has(u)||x.set(u,[]),x.get(u).push(A),null!==i.facetLevel){const t=s[Ya[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[Ya[i.seriesLevel]];null!=t&&t<(null!==(c=w.get(S))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&w.set(S,t)}}const k=[...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)})),O=k.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}})),N=new Set;for(const t of O)for(const i of t.points)N.add(i.seriesKey);const A=[...N].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 R=null,L=0;for(const t of O)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===R&&(R={xMin:t[0],xMax:t[0],yMin:s[0],yMax:s[0],sizeMax:0});for(const i of t)R.xMin=Math.min(R.xMin,i),R.xMax=Math.max(R.xMax,i);for(const t of s)R.yMin=Math.min(R.yMin,t),R.yMax=Math.max(R.yMax,t);for(const t of e)R.sizeMax=Math.max(R.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:O,series:A,extents:R,warnings:u,totalPoints:L}}class qa{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:z(e.x),y:z(e.y)});const c=new Ba;let u=[];try{""!==s&&(u=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=yi(t)}const d=(null!=u?u:[]).map((t=>c.adapt(t)));this.data=Ja(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 U(this.config.x.measure)}get yPercent(){return U(this.config.y.measure)}get sizePercent(){return U(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=wa(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}=x(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=S(i,e,"bubble");return{label:t,treatment:n,fill:this.treatmentFill(n,s,e)}}toString(){const t=new Eh;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 Ga(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 k,O=3*d,N={x:0,y:0,width:0,height:0},A=[];const R=Math.max(1,this.data.facets.length),L=null===(i=this.config.facet)||void 0===i?void 0:i.columns,T=Na.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}),E=Na.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-O-w);N={x:f.left+O,y:f.top+x+M,width:t,height:t/this.config.aspect},k=new Ma(R,L,N,this.styles.scaleFactors.panelGap*d);const i=k.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*d)))),e=new Na(E[0],E[1],i,0);A=e.ticks(s);const n=Ra(A,this.yPercent);O=Math.max(...A.map((t=>this.textWidth(Aa(t,n,this.styles.locale,this.yPercent)))),d)+this.styles.scaleFactors.axisTickLength*d+.4*d}this.canvasHeight=N.y+N.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,N.y-.6*d,"start");const P=this.buildPanels(k,T,E),C=P[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(P[0].rect.width/(7*d))))),W=Ra(C,this.xPercent),D=Ra(A,this.yPercent),z=this.config.sizeAreaPerUnit>0?Ua.grouped(this.config.sizeAreaPerUnit):Ua.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,P[0],{key:"",points:[]},z,C,A,W,D,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(p,P[i],t,z,C,A,W,D,k.isOuterLeft(i),k.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==$&&this.drawAxisTitleText(p,this.config.x,v,N.x+N.width,N.y+N.height+2.6*d,"end"),b&&("right"===this.config.legend.position?g.draw(p,m,N.x+N.width+d,N.y,"right"):g.draw(p,m,N.x,N.y+N.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 Na(i[0],i[1],r.x,r.x+r.width),h=new Na(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new Fa(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"),x=new za(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=S(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=S(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),x.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=ga(t,s.key,this.config);null===(p=this.drawBubble(w,h,a,l,o,n,r))||void 0===p||p.attr(as(c,"element")),x.registerMark(h,a,l),void 0!==t.share&&l>0&&(null===(g=this.drawShareSlice(w,h,a,l,t.share,$(r)))||void 0===g||g.attr(as(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,x,_,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=Aa(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:$a(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(as(ga(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),Na.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const Ka=["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"],Qa=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="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new qa(new se(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()),wi(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 Ka){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 fe(new pe,new ne,new ue(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};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{position:relative;display:inline-block}';const Za=["measure","label","unit"];function tl(t){const i=[],s=rl(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:nl(t,Za),invalidFields:i};const e={measure:s.trim()};return e.label=rl(t,"label",i),e.unit=rl(t,"unit",i),{config:e,unknownKeys:nl(t,Za),invalidFields:i}}const il=["show","decimals"];function sl(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:nl(t,il),invalidFields:s}}function el(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 nl(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function rl(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}const ol=["pl1","pp1","fc1"],hl=class{validateFilter(t){const i="ERR_filter";p(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=el(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=F(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";L(t)||G(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";T(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}=ks(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",sl(e,this.labelDefaults())):this.errors.remove(s)}validateScale(t){const i="WARN_scale";if(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-bullet-renderer");const{mode:t}=ii(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}=Xt(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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(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}=ks(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,tl(o))}validateEnum(t,i,s,e,n){L(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}=ks(this.actual,"measure");if(o)return null;const h=null!==r?tl(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}=ks(this.target,"measure");if(n)return null;const r=null!==e?tl(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=ol.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 j.ROWGROUP;if("category"===s)return j.CATEGORY;if("subcategory"===s)return j.SUBCATEGORY;const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==e&&""!==e){const t=j[e.toUpperCase()];if(void 0!==t)return t}return j.CATEGORY}prepareOrder(){var t,i,s,e;const n="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let r;L(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=I[null===(s=this.orderDirection)||void 0===s?void 0:s.toUpperCase()])&&void 0!==e?e:I.ASC;if(L(r))return new B([Y.CATEGORYINDEX],o);const h=r.split(",").map((t=>Y[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new B(h.length>0?h:[Y.CATEGORYINDEX],o)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{show:t.show,decimals:t.decimals}:sl(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(g.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries(),...ie(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 rs(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=di(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 xs(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=el(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:Xt(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}]}}};hl.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 al{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 ll{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new al(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 al(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}class cl{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=yi(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===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY} as category`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP} as category`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY}`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP}`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.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=wa(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?"":Oa.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 Zs(this.ruleSet.getScenarioColorIndex(s))}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:Oa.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":Oa.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new Eh;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:si(n.axisLineWidth,this.em)}).attr(ss,"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:si(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(as(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=Na.niceStep(b,4),w=Math.ceil(b/y-1e-9*y)*y,x=new Na(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(as(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:si(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),_=Na.tickDecimals(M),k=p+n;for(const i of M){const s=x.scale(i);t.line(s,k,s,k+a.axisTickLength*h).stroke({color:this.styles.axisStyles.ac.stroke,width:si(a.axisLineWidth,this.em)}),this.drawText(t,Oa.number(i,"decimal",_,_,1,this.styles.locale),s,k+a.tickStripHeight*h-.2*h,{anchor:"middle"})}}))}drawValueText(t,i,s,e,n){""!==i&&this.drawText(t,i,s,e+.35*this.em,{}).attr(as(this.rowKey(n),"label"))}rowKey(t){return Object.assign(Object.assign({},us(this.config.level,t.category)),{scenario:this.config.actual.measure})}}class ul{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 dl{adapt(t){const i=new ul;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 ul}}class fl{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 vl{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 fl(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const pl=["bullet-target-missing","bullet-target-invalid","bullet-actual-negative","bullet-mixed-operation","bullet-target-none"],gl=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=j.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new cl(new se(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()),wi(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 pl){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 vl(new dl,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};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{position:relative;display:inline-block}';const ml={rowGroup:0,category:1,subCategory:2},bl=class{validateFilter(t){const i="ERR_filter";p(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=>Ds(t)))}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];L(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"];L(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=>Gs(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>Us(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>Is(t)))}validateAspect(t){const i="WARN_aspect";L(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";T(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(L(t))return void this.errors.remove(i);const{mode:s,factor:e}=ii(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),l(this),Zt(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=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(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(){Bs(this.element,"bn-chart-scatter-renderer");const{mode:t}=ii(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}=Xt(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(){Ss(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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}=ks(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:Ls(h),c=null!==(s=h.measure)&&void 0!==s?s:"";P(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}=ks(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}=ks(i,"measure");if(e||null===s)return null;const{config:n}=Ls(s);return null!==n&&P(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}=ks(this.iso,null);return i||null===t?null:Ds(t).config}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=ks(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:Us(i,t).config}prepareLegend(){const{data:t,parseError:i}=ks(this.legend,null);return i||null===t?{show:!0,position:"right"}:Is(t).config}prepareFacet(){const{data:t,parseError:i}=ks(this.facet,null);return i||null===t?null:Gs(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(W(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&&ml[n]>=ml[e]&&(o=`series '${n}' vs point '${e}'`),null!==r){const t=null!=n?n:e;ml[r]>=ml[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(g.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 rs(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=di(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 xs(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=ii(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=Xt(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}]}}};bl.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 yl{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=yl.ladderValues(s(.25),s(.75));if(e.length<2&&(e=yl.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 wl{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:z(e.x),y:z(e.y)});const a=new Ba;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=yi(t)}const c=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=Ja(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 U(this.config.x.measure)}get yPercent(){return U(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=wa(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}=x(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),S(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 Eh;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 Ga(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,k=1.4*u+(""!==M?1.3*u:0);let O,N=3*u,A={x:0,y:0,width:0,height:0},R=[];const L=Math.max(1,this.data.facets.length),T=null===(s=this.config.facet)||void 0===s?void 0:s.columns,E=Na.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}),P=Na.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-N-x);A={x:d.left+N,y:d.top+S+_,width:t,height:t/this.config.aspect},O=new Ma(L,T,A,this.styles.scaleFactors.panelGap*u);const i=O.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new Na(P[0],P[1],i,0);R=e.ticks(s);const n=Ra(R,this.yPercent);N=Math.max(...R.map((t=>this.textWidth(Aa(t,n,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=A.y+A.height+k+("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,A.y-.6*u,"start");const C=this.buildPanels(O,E,P),W=C[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(C[0].rect.width/(7*u))))),D=Ra(W,this.xPercent),z=Ra(R,this.yPercent);let U=!1;y&&(E[0]>0&&P[0]>0?U=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,C[0],{key:"",points:[]},W,R,D,z,!0,!0,U):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,C[i],t,W,R,D,z,O.isOuterLeft(i),O.isOuterBottom(i),U,this.data.facets.length>1?t.key:"")})),""!==M&&this.drawAxisTitleText(v,this.config.x,f,A.x+A.width,A.y+A.height+2.6*u,"end"),m&&("right"===this.config.legend.position?p.draw(v,g,A.x+A.width+u,A.y,"right"):p.draw(v,g,A.x,A.y+A.height+k,"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 Na(i[0],i[1],r.x,r.x+r.width),h=new Na(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new Fa(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 za(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(as(ga(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(as(ga(c.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new yl(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:si(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:yl.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=>Na.stepDecimals(Math.abs(t)))));return t.map((t=>Aa(t,i,this.styles.locale)))}}const xl=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],Sl=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="",l(this)}getDb(){return this.stores||(this.stores=u(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=M(this.getDb(),this.tableName,this.filter);this.chart=new wl(new se(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()),wi(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 xl){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 fe(new pe,new ne,new ue(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(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)}};Sl.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 $l=class{validateFilter(t){const i="ERR_filter";p(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(qt(t)||H(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)||J(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(qt(t))return void this.errors.remove(i);const s=F(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";qt(t)||L(t)||G(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";T(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";q(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){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const s=`WARN_${t}`;!T(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(s)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",L(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",L(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,s){const e=`WARN_${t}`;i?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+s+"' is not supported."})}prepareReferenceLine(){if(L(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(L(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",s=K(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.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",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: ${$l.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${ni(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: ${$l.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(this).t,this.resolveInherited=ri(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.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),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.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Bs(this.element,"bn-chart-structure-renderer");const{mode:t}=ii(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}=Xt(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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Xt(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=Xt(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 _(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===ei(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=ii(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)`),_(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=Xt(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{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()));if(H(n.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return L(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 L(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&H(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=g,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(),...ie(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=ei(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: ${$l.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=ei(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: ${$l.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 L(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}`}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[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 L(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:I[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,titleBold:i["bn-chart-structure"].titleBold,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),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);const e="total"===t.thickness,n=e&&this.prepareVariances().length>0;return n?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||tt.ABSOLUTE,order:t.order||Z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:e&&!n?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),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 L(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){var e;const n=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),o=this.prepareStackConfig(),h=""===t,a=this.hidesScenarios()?qs([t]):this.prepareScenarios(),l=h&&(null==o?void 0:o.by)===Q.DIMENSIONS?a.slice(0,1):a;return i("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:l,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:n,pixelPerPercentage:r,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:o,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:h?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return rs(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=di(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=ws(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-structure-renderer"),f={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:li(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:ai(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=ei(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=ei(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}=ii(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(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const e=this.getFontStyles();return i(s,{key:"132c843c3a3b2a3780acf89370b6a6eb75c10170",style:e},i("div",{key:"84a2f28b516bfc71ca8145158cc48d9dcbcb46c4",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}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};$l.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 Ml=class{constructor(t,i,s,e,n,r,o,h,a=!1,l=null){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.rows=l,this.leftSideLabelLength=this.calculateSideLabelLength(r,o,h),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){if(this.rows&&t<this.rows.start.length){const i=this.rows.start[t]+this.rows.weight[t]/2;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}isNameBelowBar(){var t;return!!(null===(t=this.rows)||void 0===t?void 0:t.nameBelowBar)}getRowTopPositionY(t){const i=this.rows&&t<this.rows.start.length?this.rows.start[t]:t;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}getBarWidthAt(t){return this.spacings.barWidth*(this.rows&&t<this.rows.weight.length?this.rows.weight[t]:1)}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.getBarWidthAt(0)-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(){const t=this.rows?this.rows.total:this.numberOfColumns;return this.getAxisPositionY()+(t+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){var i;if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return(null===(i=this.rows)||void 0===i?void 0:i.nameBelowBar)?t: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}},_l=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}},kl=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}},Ol=class{constructor(t){this.container=new Eh,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 Nl,Al,Rl;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Nl||(Nl={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Al||(Al={})),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"}(Rl||(Rl={}));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,Rl[t])}}Ll.unitsGreat=["k","M","G","T","P","E","Z","Y"],Ll.unitsLeast=["m","my","n","p","f","a","z","y"];class Tl{adapt(t){return it.adaptDefaultString(t)}default(){return""}}class El{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 st(new Tl).default(),this.level=j.CATEGORY,this.filter="",this.measureScale=new La,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[]}}class Pl{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=it.adaptArray(t.data,this.dataRowAdapter),s=it.adaptArray(t.scenarios,this.stringAdapter),e=new El(i,s);return R.isArray(t.variances)&&(e.variances=it.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),R.isString(t.sums)&&["groups","total","all"].includes(t.sums)&&(e.sums=t.sums),R.isString(t.sumTitle)&&(e.sumTitle=t.sumTitle),R.isString(t.valueSuffix)&&(e.valueSuffix=t.valueSuffix),R.isBoolean(t.scenarioLabelTop)&&(e.scenarioLabelTop=t.scenarioLabelTop),R.isBoolean(t.hideScenarioName)&&(e.hideScenarioName=t.hideScenarioName),R.isExisting(t.referenceLine)&&(e.referenceLine=t.referenceLine),R.isArray(t.italicCategories)&&(e.italicCategories=it.adaptArray(t.italicCategories,this.stringAdapter)),e}default(){return new El([],[])}}let Cl=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?Js(e,null,!0):e;this.variance="neg"===n||n===jl.NEG?jl.NEG:"pos"===n||n===jl.POS?jl.POS:jl.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:jl.NEU===this.variance?jl.NEU:jl.POS===this.variance?jl.NEG:jl.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 Wl{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 Dl{constructor(){}adapt(t){const i=new Wl;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 Wl}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 zl{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.titleBold=!1,this.valueSuffix="",this.locale="de"}}class Ul{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 zl(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.titleBold=!0===t.titleBold,i.pattern=new kl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new zl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class Fl{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 Gl{adapt(t){const i=new Fl;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 Fl}}var jl,Il,Bl;!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"}(jl||(jl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Il||(Il={})),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"}(Bl||(Bl={}));class Yl{constructor(t,i,s,e,n,r,o,h){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.bold=!1,this.italic=!1,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||Bl.Top,this.horizontalHookLocation=h||Bl.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setEmphasis(t,i){return this.bold=t,this.italic=i,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,e,n,r;if(this.isEmpty())return this;const o=this.group;let h;const a=this.styles.fontStyles.background||"#ffffff";let l="";if(!1===Number.isNaN(Number(this.value))){let e=t.percent,n=t.percent,r=1,o="percent";!1===this.isRelativeLabel&&(e=t.decimal,n=t.decimal,r=i.value,o="decimal"),h=Oa.number(Number(this.value),o,e,n,r,this.styles.locale);const a=Oa.number(0,o,e,n,r,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&h!==a&&(l="+"),"number"!=typeof this.value||this.isVarianceLabel||this.isRelativeLabel||(h+=null!==(s=this.styles.valueSuffix)&&void 0!==s?s:"")}else h=""+this.value;const c=o.text(l+h);(null===(e=this.styles.fontStyles)||void 0===e?void 0:e.size)&&c.attr("font-size",this.styles.fontStyles.size),(null===(n=this.styles.fontStyles)||void 0===n?void 0:n.family)&&c.attr("font-family",this.styles.fontStyles.family),this.bold&&c.font({weight:"bold"}),this.italic&&c.font({style:"italic"}),c.move(this.x,this.y);const u=c.bbox(),d=u.w,f=u.h;if(null!=this.maxWidth&&d>this.maxWidth)return null===(r=this.group)||void 0===r||r.remove(),this.group=null,this;let v="start";return this.horizontalHookLocation===Bl.Right?(v="end",c.move(c.x()-c.length(),c.y())):this.horizontalHookLocation===Bl.Center&&(v="middle",c.move(c.x()-c.length()/2,c.y())),this.verticalHookLocation===Bl.Center?c.move(c.x(),c.y()-f/2):this.verticalHookLocation===Bl.Bottom&&c.move(c.x(),c.y()-f),c.font({anchor:v}),null!=this.segmentFillColor?c.fill($a(this.segmentFillColor)):null==o||o.rect(d,.9*f).stroke(a).fill(a).opacity(.7).move(c.x(),c.y()+.1*f).insertBefore(c),this.pointKey&&(null==o||o.attr(as(this.pointKey,this.pointPart))),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Hl=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 Yl(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Bl.Bottom,Bl.Center).setEmphasis(this.style.titleBold,!1),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 Vl{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=Bl.Left;s.value<0&&(i=Bl.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Yl(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Bl.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}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),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,n;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let r=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(r=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const o=this.convertToSVGStyle(r,"stroke");let h=this.convertToSVGStyle(r,"fill");const a=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=a){const t=this.styles.pattern.get(a);null!=t&&(h=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(as(this.dataPoint.key)),null===(e=this.barGroup)||void 0===e||e.attr(as(this.dataPoint.key,"element")),this.isVarianceBar||null===(n=this.barGroup)||void 0===n||n.attr("data-bn-value",this.dataPoint.value),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(h,o):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(h).stroke(o).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(){if(null!=this.scenarioLabel&&!this.scenarioLabel.isEmpty()&&!this.isVarianceBar){let t=this.dimensions.scenarioLabelXPos;if(this.nameBesideAxis()){const i=this.dataPoint.getScaledUnit()<0?-1:1;t=this.position.getBarPositionX()+i*this.position.spacings.labelToAxis}this.scenarioLabel.setPos(t,this.dimensions.scenarioLabelYPos).draw()}}nameBesideAxis(){return this.isPrimaryBar&&this.position.isNameBelowBar()}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){if(this.isPrimaryBar){let i=Bl.Center;return this.nameBesideAxis()&&(i=this.dataPoint.getScaledUnit()<0?Bl.Right:Bl.Left),new Yl(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Bl.Top,i)}return new Yl(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,Bl.Bottom,Bl.Center)}}let Xl=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 Yl(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Bl.Bottom:Bl.Top,Bl.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(as(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(as(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)}},Jl=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=Bl.Left;s.value<0&&(i=Bl.Right),this.label=new Yl(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,r?et:s.value,this.styles,Bl.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),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}){var i,s,e;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(as(this.dataPoint.key)),this.barGroup.attr(as(this.dataPoint.key,"element"));const n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),r=n.stroke;let o=n.fill;const h=this.barStyles[this.dataPoint.getScenario()];if(null!=h&&h.fillpattern){const t=this.styles.pattern.get(h.fillpattern);null!=t&&null!=t.pattern&&(o=t.pattern)}this.drawNeedleHead(o,r),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(e=this.label)||void 0===e||e.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,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 ql{constructor(t,i,s,e,n,r,o,h,a,l,c,u={}){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.options=u,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){var s;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const e=this.dataPoint.value,n=this.dataPoint.pixelPerUnit,r=this.position.getBarPositionX(),o=this.position.getBarWidthAt(this.index),h=Math.abs(this.segment.end-this.segment.start)*n,a=r+Math.min(this.segment.start,this.segment.end)*n,l=this.position.getBarPositionY(this.index,!0),c=this.styles.stackColors,u=c[this.segmentIndex%c.length],d={color:u},f={color:u,width:.5};this.barGroup.attr(as(this.dataPoint.key,"element")),this.barGroup.attr("data-bn-value",e),this.barGroup.rect(Math.max(h,.5),o).fill(d).stroke(f).cy(l).x(a);const v=h-Math.min(6,.375*this.styles.fontStyles.size),{bold:p=!1,italic:g=!1}=this.options,m=this.stackMode===tt.RELATIVE&&null!==(s=this.options.label)&&void 0!==s?s:"share";if(v>0){const s=a+h/2;if(this.stackMode!==tt.RELATIVE&&this.stackMode!==tt.ABSOLUTE_RELATIVE||"value"===m)new Yl(this.group,s,l,"STACK_SEG",e,this.styles,Bl.Center,Bl.Center).setSegmentFill(u).setEmphasis(p,g).setMaxWidth(v).setPoint(this.dataPoint.key).draw(t,i);else{const i="plain-share"===m?Oa.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):Oa.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new Yl(this.group,s,l,"STACK_SEG",i,this.styles,Bl.Center,Bl.Center).setSegmentFill(u).setEmphasis(p,g).setMaxWidth(v).setPoint(this.dataPoint.key).draw()}}}drawTotalLabel(t={percent:2,decimal:1},i=new La,s){var e,n;if(this.stackMode===tt.RELATIVE&&!this.options.total)return;const r=this.stack.total<0,o=this.position.getLabelPositionX((r?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),h=this.position.getBarPositionY(this.index,!0);new Yl(this.group,o,h,"STACK_TOTAL",this.stack.total,this.styles,Bl.Center,r?Bl.Right:Bl.Left).setEmphasis(null!==(e=this.options.bold)&&void 0!==e&&e,null!==(n=this.options.italic)&&void 0!==n&&n).setPoint(s,"total").draw(t,i)}}let Kl=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 Vl(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 Vl(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 Jl(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 Vl(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 Xl(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 Xl(this.position,n,r,t.scenario,this.styles,t,i,o,!1)}isFirstDataPoint(t){return 0===t}};const Ql=.001;function Zl(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 tc(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 ic(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Ql,(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 sc(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 ec(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 nc(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 rc{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new Cl(0,jl.AC1,1,jl.NEU),this.highestDataPointValue=new Cl(0,jl.AC1,1,jl.NEU),this.smallestVarianceDataPointValue=new Cl(0,jl.AC1,1,jl.NEU),this.highestVarianceDataPointValue=new Cl(0,jl.AC1,1,jl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=j.CATEGORY,this.hideCategories=!1,this.axisScenario=jl.AC1,this.CSS_CATEGORIES="categories",this.state=Nl.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=ec([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.db=i,this.tableName=s,this.ruleSet=t||new se,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 Ml(new _l(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||this.scenarioLabelTop,this.rowLayout())}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new se}setConfig(t){var i,s;this.state=Nl.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.sums=t.sums,this.sumTitle=t.sumTitle,this.styles.valueSuffix=t.valueSuffix,this.scenarioLabelTop=t.scenarioLabelTop,this.hideScenarioName=t.hideScenarioName,this.referenceLine=t.referenceLine,this.italicCategories=t.italicCategories,this.dataModel=this.populateModel(e,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==Q.SCENARIOS&&this.populateDimensionStackSegments(e,t.stackConfig,t.level),this.addSumRows(e);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({},us(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));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();const n=this.dataModel.filter((t=>!t.sum));this.smallestDataPointValue=this.findSmallestDataPointValue(n),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(n),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||Oa.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=Nl.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=Nl.DIRTY,this.queryError=void 0,this.fromExpr=M(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=yi(t))}getUnitBarExtent(){var t,i,s,e;const n=this.isStacked(),r=this.getVarianceType(),o=r!==Al.NONE,h=o?this.highestVarianceDataPointValue:this.highestDataPointValue,a=o?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Zl({fixedDomain:n?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:r===Al.RELATIVE,maxPositive:Math.max(null!==(t=null==h?void 0:h.value)&&void 0!==t?t:0,n||o?0:null!==(s=null===(i=this.referenceLine)||void 0===i?void 0:i.value)&&void 0!==s?s:0),minNegative:null!==(e=null==a?void 0:a.value)&&void 0!==e?e:0})}getPercentBarExtent(){var t,i,s,e;return tc({relativeVariance:this.getVarianceType()===Al.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.hasPercentMark()?.8*this.position.fontSize:0)+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new Eh)}toString(){const t=new Eh;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===Nl.DIRTY&&(this.state=Nl.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.drawPercentMark(t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)),0===this.variancesDataModel.length&&this.drawReferenceLine(t)}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=wa(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:this.styles.titleBold?"bold":"normal"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Oa.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=te(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=jl.AC1;if(null!=t&&t.length>0){const s=new Xs(t.toString());s.isValid&&(i=Zs(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=jl.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 Xs(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 Cl(n(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,jl.NEU),scenario2:new Cl(n(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,jl.NEU),scenario3:new Cl(n(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,jl.NEU),scenario4:new Cl(n(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,jl.NEU)}}),{id:9999,category:"REST",type:Al.NONE,scenario1:new Cl(NaN,i[0],this.pixelPerUnit,jl.NEU),scenario2:new Cl(NaN,i[1],this.pixelPerUnit,jl.NEU),scenario3:new Cl(NaN,i[2],this.pixelPerUnit,jl.NEU),scenario4:new Cl(NaN,i[3],this.pixelPerUnit,jl.NEU)});s.push(r)}createDataRows(t,i,s){t.forEach(((t,e)=>{i.push({id:e,category:t.category,type:Al.NONE,scenario1:new Cl(t[s[0]],s[0],this.pixelPerUnit,jl.NEU),scenario2:new Cl(t[s[1]],s[1],this.pixelPerUnit,jl.NEU),scenario3:new Cl(t[s[2]],s[2],this.pixelPerUnit,jl.NEU),scenario4:new Cl(t[s[3]],s[3],this.pixelPerUnit,jl.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===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY} as category`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP} as category`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===j.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${j.CATEGORY}`:t===j.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${j.ROWGROUP}`:t===j.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${j.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=wa(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 Cl(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 Cl(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===tt.RELATIVE?1:0,n=(t,i)=>({prefix:t,segments:i,layout:sc(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=Sa(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of xa)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=ec(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return nc(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===tt.RELATIVE&&"value"!==this.stackConfig.labels?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.isTextSum(t)?[]:this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return wa(Oa.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix,{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 Xs(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 Cl(this.calculateVariance(r,i[e],o),r.base,a,h);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},us(this.level,i[e].category)),{scenario:t[n]})),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Al.RELATIVE:Al.ABSOLUTE,scenario1:l,scenario2:new Cl(null,null,null,null),scenario3:new Cl(null,null,null,null),scenario4:new Cl(null,null,null,null),sum:i[e].sum})}}}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===Al.RELATIVE?nt(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,i=!1){const s=i?"":this.styles.valueSuffix;return wa(Oa.number(t,"decimal",1,0,1,this.styles.locale)+s,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,e=t=>Oa.number(t,"percent",s,s,1,this.styles.locale);return t>0&&e(t)!==e(0)&&(i+=wa("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=wa(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,wa(Oa.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)=>{var r;t.type===Al.RELATIVE&&(n=!0);let o=Bl.Right,h=!0,a=0;if(s){const i=this.stackLabelPlace(t);h=!i.flipped,a=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&!this.hasSumNumbers(this.dataModel[i])&&(h=!1);h||(o=Bl.Left),new Yl(e,this.position.getCategoryPositionX(h)+a,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Bl.Center,o).setEmphasis(!!(null===(r=this.dataModel[i])||void 0===r?void 0:r.sum),this.isItalic(t.category)).draw()})),t.forEach(((t,i)=>{const s=this.dataModel[i];if(!(null==s?void 0:s.sum))return;const n=this.position.getBarCenterPositionY(i)-this.position.spacings.categoryWidth/2,r=this.hideCategories?this.position.getAxisPositionX():this.styles.padding.left;e.line(r,n,this.position.getAxisPositionX()+this.sumRowExtent(s),n).stroke({color:"#000000",width:Math.max(.5,this.position.spacings.axisLineWidth/2)}).addClass("sum-line")})),new Hl({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios");let e=-1;t.forEach(((t,i)=>{t.sum||(e=i)}));const n=new Kl(this.position,s,this.scenarioStyles(),this.scenarioLabelTop?0:e+1,this.i18n);n.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.sum?this.drawSumValue(t,i,s):(n.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),n.createSecondaryBar(t.scenario2,i).draw(),n.createPrimaryMarker(t.scenario3,i).draw(),n.createSecondaryMarker(t.scenario4,i).draw())}));const r=t.find((t=>!t.sum));if(this.scenarioLabelTop&&r&&!r.scenario1.isEmpty()&&null!=r.scenario1.scenario){const t=r.scenario1.scenario;new Yl(s,this.position.getBarPositionX()+this.position.spacings.labelToAxis,this.position.getStackedHeaderPositionY(),"SCENARIO_HEADER",this.i18n.get(t)||t,this.styles,Bl.Bottom,Bl.Left).draw()}}sumPoints(t){const i=[t.scenario1,t.scenario2,t.scenario3,t.scenario4].filter((t=>null!=t&&!t.isEmpty()&&Number.isFinite(t.value))),s=this.scenarioPropOrder,e=t=>{const i=s.indexOf(t.scenario);return-1===i?s.length:i};return i.sort(((t,i)=>e(t)-e(i)))}hasSumNumbers(t){return!!(null==t?void 0:t.sum)&&0===this.variancesDataModel.length&&!this.stackConfig&&this.sumPoints(t).length>1}sumValuesWidth(t){const i=this.styles.fontStyles.size,s=i*this.styles.scaleFactors.labelToBar,e=this.sumPoints(t);if(0===e.length)return 0;const n=e.map((t=>this.boldWidth(this.sumText(t.value))));return 1===e.length?s+n[0]:s+n.reduce(((t,s)=>t+.9*i+s),0)+(e.length-1)*i*1.4}drawSumValue(t,i,s){const e=this.sumPoints(t);if(0===e.length)return;const n=this.styles.fontStyles.size,r=this.position.getBarCenterPositionY(i),o=s.group().id(`sum_${i}`),h=(t,i,s)=>{new Yl(o,i,r,`SUM_${t.scenario}`,t.value,this.styles,Bl.Center,s).setEmphasis(!0,!1).setPoint(t.key).draw(this.dataFormatDigits,this.measureScale)};if(1===e.length){const t=e[0].value<0;return void h(e[0],this.position.getLabelPositionX(t?-1e-6:0),t?Bl.Right:Bl.Left)}const a=.6*n,l=this.scenarioStyles().barStyles;let c=this.position.getLabelPositionX(0);for(const t of e){const i=l.getSVGStyle(t.getScenario());o.rect(a,a).fill({color:(null==i?void 0:i.fill)||"#000000"}).stroke({color:(null==i?void 0:i.stroke)||"#000000",width:1}).cy(r).x(c),h(t,c+a+.3*n,Bl.Left),c+=.9*n+this.boldWidth(this.sumText(t.value))+1.4*n}}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Kl(this.position,s,this.scenarioStyles(),t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{if(t.type===Al.RELATIVE){const s=e.createRelativeVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits)}else{const s=e.createVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.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,n=this.stackConfig.mode===tt.RELATIVE&&"value"===this.stackConfig.labels,r=n?"value":this.stackConfig.percentMark?"plain-share":"share";t.forEach(((t,i)=>{const o=this.stackGroups(t);if(this.isTextSum(t))return void this.drawSumText(t,i,s);const h={label:r,total:n,bold:!!t.sum,italic:this.isItalic(t.category)};o.forEach(((n,r)=>{let a=null;n.segments.forEach(((t,l)=>{const c=new ql(this.position,this.styles,t.dataPoint,i,n.layout.segments[l],t.scenario,o.length>1?o.length-1-r:l,this.stackConfig.mode,n.layout,e,s,h);c.draw(this.dataFormatDigits,this.measureScale),a=c})),a&&n.hasValue&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},us(this.level,t.category)),{scenario:o.length>1?n.prefix:void 0}))}))}))}drawStackedHeaders(t,i){var s;if(!this.stackConfig||0===t.length)return;const e=null!==(s=t.find((t=>!this.isTextSum(t))))&&void 0!==s?s:t[0];if(this.stackConfig.by!==Q.SCENARIOS&&(!e.stackSegments||0===e.stackSegments.length))return;const n=this.stackGroups(e);if(0===n.length)return;const r=i.group().id("StackedHeaders"),o=this.position.getBarPositionX(),h=this.position.getStackedHeaderPositionY(),a=(t,i)=>{new Yl(r,t,h,"STACK_HEADER",i,this.styles,Bl.Bottom,Bl.Center).draw()};if(n.length>1)return void n.forEach((t=>{a(o+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[l]=n;this.stackConfig.totalTitle&&(this.stackConfig.mode!==tt.RELATIVE||"value"===this.stackConfig.labels)&&new Yl(r,this.position.getLabelPositionX(l.layout.positive*this.pixelPerUnit),h,"STACK_TOTAL_HEADER",this.stackConfig.totalTitle,this.styles,Bl.Bottom,Bl.Left).draw(),l.segments.forEach(((t,i)=>{const{start:s,end:e}=l.layout.segments[i];a(o+(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}stackHeaderExtent(){var t;if(!this.stackConfig||0===this.dataModel.length)return 0;const i=null!==(t=this.dataModel.find((t=>!this.isTextSum(t))))&&void 0!==t?t:this.dataModel[0],s=this.stackGroups(i);if(1!==s.length)return 0;const[e]=s;let n=0;return e.segments.forEach(((t,i)=>{const{start:s,end:r}=e.layout.segments[i],o=String(this.i18n.get(t.scenario)||t.scenario),h=wa(o,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;n=Math.max(n,(s+r)/2*t.dataPoint.pixelPerUnit+h/2)})),n}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Al.NONE}calculateLeftSideWidth(t){var i,s,e,n,r;let o=0;const h=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Al.NONE===t&&this.isStacked()){if(this.stackSides.negative>0){o=this.stackSides.negative*this.pixelPerUnit;const t=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);this.stackSides.minTotal<0&&t&&(o+=h+this.calculateTotalLabelWidth(this.stackSides.minTotal))}this.stackLabelClearance.left>0&&(o=Math.max(o,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()))}else if(Al.NONE===t&&null!=(null===(e=this.smallestDataPointValue)||void 0===e?void 0:e.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);o=Math.abs(this.smallestDataPointValue.getScaledUnit())+h+t}else if(Al.RELATIVE===t&&null!=(null===(n=this.smallestVarianceDataPointValue)||void 0===n?void 0:n.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);o=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+h+t}else if(Al.ABSOLUTE===t&&null!=(null===(r=this.smallestVarianceDataPointValue)||void 0===r?void 0:r.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value,!0);o=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+h+t}return o<=this.titleLength?this.titleLength:o}calculateRightSideWidth(t){var i,s,e,n,r,o,h,a;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,o=(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE||"value"===(null===(s=this.stackConfig)||void 0===s?void 0:s.labels);let h=t+this.calculateTextBoxWidth(this.stackSides.maxTotal);o||(h=this.hasPercentMark()?this.boldWidth("100%")/2:0);let a=Math.max(this.stackSides.positive*this.pixelPerUnit+h,this.stackHeaderExtent());if(this.stackSides.minTotal<0&&(a=Math.max(a,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),(null===(e=this.stackConfig)||void 0===e?void 0:e.totalTitle)&&o){const i=wa(this.stackConfig.totalTitle,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;a=Math.max(a,this.stackSides.positive*this.pixelPerUnit+t+i)}return Math.max(a,this.titleLength,null!==(r=null===(n=this.sumColumns())||void 0===n?void 0:n.width)&&void 0!==r?r:0,this.referenceLineExtent())}let l=0;const c=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Al.NONE===t&&null!=(null===(o=this.highestDataPointValue)||void 0===o?void 0:o.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);l=Math.abs(this.highestDataPointValue.getScaledUnit())+c+t}else if(Al.RELATIVE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);l=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+c+t}else if(Al.ABSOLUTE===t&&null!=(null===(a=this.highestVarianceDataPointValue)||void 0===a?void 0:a.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value,!0);l=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+c+t}l=Math.max(l,this.referenceLineExtent());for(const i of this.dataModel)i.sum&&Al.NONE===t&&(l=Math.max(l,this.sumRowExtent(i)));return l<=this.titleLength?this.titleLength:l}populateDimensionStackSegments(t,i,s){var e;if(0===this.rowCount||!this.fromExpr||0===t.length)return;const n={[j.ROWGROUP]:"category",[j.ROWGROUPINDEX]:"category",[j.CATEGORY]:"subCategory",[j.CATEGORYINDEX]:"subCategory"}[s];if(!n)return;const r=s.toString(),o=t[0];let h;try{h=this.db.exec(`SELECT [${r}] as displayGroup, [${n}] as stackLabel, MIN([${n}Index]) as stackIndex, SUM([${o}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${r}], [${n}]`)}catch(t){return void this.failQuery(t)}const a=new Map;for(const t of h){if(null==t.stackValue||null==t.stackLabel)continue;const i=t.stackLabel,s=Number.isFinite(Number(t.stackIndex))&&null!=t.stackIndex?Number(t.stackIndex):NaN,e=a.get(i);(void 0===e||Number.isNaN(e)&&!Number.isNaN(s)||s<e)&&a.set(i,s)}const l=[...a.keys()];[...a.values()].every((t=>!Number.isNaN(t)))&&l.sort(((t,i)=>a.get(t)-a.get(i)));const c=new Map;for(const t of h){const i=t.displayGroup;c.has(i)||c.set(i,new Map),null!=t.stackValue&&null!=t.stackLabel&&c.get(i).set(t.stackLabel,t.stackValue)}const u=new Set(this.dataModel.map((t=>t.category))),d=new Map;for(const[t,i]of c)if(!u.has(t))for(const[t,s]of i)d.set(t,(null!==(e=d.get(t))&&void 0!==e?e:0)+s);for(const t of this.dataModel){const i=9999!==t.id||c.has(t.category)?c.get(t.category):d,s=i&&i.size>0?l.map((t=>{var s;return{label:t,value:null!==(s=i.get(t))&&void 0!==s?s:NaN}})):void 0;t.stackSegments=s&&s.length>0?s.map((i=>{const s=new Cl(i.value,o,this.pixelPerUnit,jl.NEU);return s.key=Object.assign(Object.assign({},us(this.level,t.category)),{[n]:i.label,scenario:o}),{label:i.label,value:i.value,dataPoint:s}})):[]}}isTextSum(t){return!!t.sum&&!!this.stackConfig&&this.stackConfig.mode!==tt.RELATIVE}isItalic(t){return this.italicCategories.includes(t)}hasPercentMark(){var t;return!!(null===(t=this.stackConfig)||void 0===t?void 0:t.percentMark)&&this.stackConfig.mode===tt.RELATIVE&&0===this.variancesDataModel.length&&this.isStacked()}addSumRows(t){if("none"===this.sums||0===this.dataModel.length)return;const i=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,s=(s,e,n)=>{var r,o;const h=(e,n)=>new Cl(void 0===t[n]?void 0:s.reduce(((t,s)=>i(t,s[e].value)),NaN),t[n],this.pixelPerUnit,jl.NEU),a={id:1e4+this.dataModel.length,category:e,type:Al.NONE,scenario1:h("scenario1",0),scenario2:h("scenario2",1),scenario3:h("scenario3",2),scenario4:h("scenario4",3),sum:n};if(s.some((t=>t.stackSegments))){const e=new Map;for(const t of s)for(const s of null!==(r=t.stackSegments)&&void 0!==r?r:[])e.set(s.label,i(null!==(o=e.get(s.label))&&void 0!==o?o:NaN,s.value));a.stackSegments=[...e].map((([i,s])=>({label:i,value:s,dataPoint:new Cl(s,t[0],this.pixelPerUnit,jl.NEU)})))}return a},e=this.dataModel,n=[],r="total"===this.sums?new Map:this.rowGroups();if(r.size>0){const t=[...new Set([...r.values()].sort(((t,i)=>t.index-i.index)).map((t=>t.name)))];for(const i of t){const t=e.filter((t=>{var s;return(null===(s=r.get(t.category))||void 0===s?void 0:s.name)===i}));if(0===t.length)continue;const o=s(t,i,"group");o.gapAfter=!0,n.push(...t,o)}n.push(...e.filter((t=>!r.has(t.category))))}else n.push(...e);"total"!==this.sums&&"all"!==this.sums||n.push(s(e,this.sumTitle||"SUM_TOTAL","total")),this.dataModel=n}rowGroups(){const t=new Map;if(this.level!==j.CATEGORY&&this.level!==j.CATEGORYINDEX)return t;let i;try{i=this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`)}catch(i){return this.failQuery(i),t}const s=new Map;return i.forEach(((i,e)=>{var n;if(null==i.rowGroup||""===i.rowGroup)return;const r=String(i.rowGroup),o=Number(i.rowGroupIndex),h=null!=i.rowGroupIndex&&Number.isFinite(o)?o:null!==(n=s.get(r))&&void 0!==n?n:e;s.has(r)||s.set(r,h),t.set(String(i.category),{name:r,index:Math.min(h,s.get(r))})})),t}rowLayout(){var t;const i=this.dataModel,s="total"===(null===(t=this.stackConfig)||void 0===t?void 0:t.thickness),e=i.reduce(((t,i,s)=>i.sum?t:s),-1),n=!this.stackConfig&&!this.scenarioLabelTop&&!this.hideScenarioName&&e>=0&&e<i.length-1;if(!s&&!n&&!i.some((t=>t.gapAfter)))return null;const r=i.map((t=>{if(!s||t.sum)return null;const i=this.stackGroups(t),e=i[i.length-1];return e?Math.abs(e.layout.total):0})),o=this.rowWeights(r),h=[],a=[];let l=0;return i.forEach(((t,s)=>{const r=o[s];h.push(l),a.push(r),l+=r+(t.gapAfter&&s<i.length-1?.5:0)+(n&&s===e?1:0)})),{start:h,weight:a,total:l,nameBelowBar:n}}rowWeights(t){const i=Math.min(1,1/this.styles.scaleFactors.categoryWidth),s=t.map((t=>null===t?1:0)),e=new Set(t.flatMap(((t,i)=>null===t?[]:[i])));let n=e.size;for(;;){const r=[...e].reduce(((i,s)=>i+t[s]),0);if(r<=0){e.forEach((t=>s[t]=n/e.size));break}const o=[...e].filter((s=>t[s]/r*n<i));if(0===o.length||o.length===e.size){e.forEach((i=>s[i]=t[i]/r*n));break}for(const t of o)s[t]=i,n-=i,e.delete(t)}return s}boldWidth(t){return wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:"bold"}).width}sumText(t){const i=this.dataFormatDigits.decimal;return Oa.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)+this.styles.valueSuffix}sumColumns(){const t=this.dataModel.filter((t=>this.isTextSum(t)));if(0===t.length)return null;const i=this.styles.fontStyles.size,s=.6*i,e=.3*i,n=1.4*i,r=[];let o=0;for(const i of t){const t=this.stackGroups(i),s=t[t.length-1];s&&(s.segments.forEach(((t,i)=>{var s;const e=Number.isFinite(t.value)?this.boldWidth(this.sumText(t.value)):0;r[i]=Math.max(null!==(s=r[i])&&void 0!==s?s:0,e)})),o=Math.max(o,this.boldWidth(this.sumText(s.layout.total))))}const h=[];let a=.3*i;for(const t of r.length>1?r:[])h.push(a),a+=s+e+t+n;return{x:h,totalX:a,width:a+o,key:s,keyGap:e}}drawSumText(t,i,s){const e=this.sumColumns(),n=this.stackGroups(t),r=n[n.length-1];if(!e||!r)return;const o=this.position.getBarPositionX(),h=this.position.getBarCenterPositionY(i),a=this.styles.stackColors,l=s.group().id(`stacked_sum_${i}`);r.segments.forEach(((t,i)=>{if(!Number.isFinite(t.value)||void 0===e.x[i])return;const s=o+e.x[i];l.rect(e.key,e.key).fill({color:a[i%a.length]}).cy(h).x(s),new Yl(l,s+e.key+e.keyGap,h,`SUM_SEG_${i}`,t.value,this.styles,Bl.Center,Bl.Left).setEmphasis(!0,!1).setPoint(t.dataPoint.key).draw(this.dataFormatDigits,this.measureScale)})),new Yl(l,o+e.totalX,h,"SUM_TOTAL",r.layout.total,this.styles,Bl.Center,Bl.Left).setEmphasis(!0,!1).setPoint(us(this.level,t.category),"total").draw(this.dataFormatDigits,this.measureScale)}sumRowExtent(t){var i,s,e;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(this.variancesDataModel.length>0)return 0;if(this.isTextSum(t))return null!==(s=null===(i=this.sumColumns())||void 0===i?void 0:i.width)&&void 0!==s?s:0;if(this.stackConfig){const i="value"===this.stackConfig.labels?n+this.boldWidth(this.sumText(null!==(e=t.scenario1.value)&&void 0!==e?e:0)):0;return this.stackSides.positive*this.pixelPerUnit+i}return this.sumValuesWidth(t)}referenceLineOffset(){var t;const i=this.referenceLine;return!i||!Number.isFinite(i.value)||this.variancesDataModel.length>0?null:((null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===tt.RELATIVE?i.value/100:i.value)*this.pixelPerUnit}referenceLineExtent(){var t;const i=this.referenceLineOffset();if(null===i||i<=0)return 0;const s=(null===(t=this.referenceLine)||void 0===t?void 0:t.label)?wa(this.referenceLine.label,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width:0;return i+Math.max(s/2,.25*this.styles.fontStyles.size)}drawPercentMark(t){if(!this.hasPercentMark())return;const i=t.group().id("PercentMark"),s=this.styles.fontStyles.size,e=this.position.getBarPositionX()+this.stackSides.positive*this.pixelPerUnit,n=this.position.getAxisPositionY(),r=this.position.getAxisEndPositionY(),o=r+.15*s,h=o+.75*s;i.line(e,n,e,r).stroke({color:"#000000",width:this.position.spacings.axisLineWidth}),i.polygon(`${e},${o} ${e-.28*s},${h} ${e+.28*s},${h}`).fill("#000000"),new Yl(i,e,h+.1*s,"PERCENT_MARK","100%",this.styles,Bl.Top,Bl.Center).setEmphasis(!0,!1).draw()}drawReferenceLine(t){const i=this.referenceLine,s=this.referenceLineOffset();if(!i||null===s||0===this.dataModel.length)return;const e=t.group().id("ReferenceLine"),n=this.styles.fontStyles.size,r=`var(--bn-annotation-color, ${a["bn-annotation"].color})`,o=this.position.getBarPositionX()+s,h=this.position.getStackedHeaderPositionY()-(this.stackConfig||this.scenarioLabelTop?1.1*n:0),l=t=>{var s,e;if(t.sum)return!1;if(!this.stackConfig)return(null!==(s=t.scenario1.value)&&void 0!==s?s:0)>=i.value;const n=null===(e=this.stackGroups(t)[0])||void 0===e?void 0:e.layout.segments[0];return null!=n&&n.end*this.pixelPerUnit>=o-this.position.getBarPositionX()};let c=this.dataModel.findIndex((t=>!l(t)))-1;c<0&&(c=this.dataModel.reduce(((t,i,s)=>i.sum?t:s),0));const u=this.position.getBarCenterPositionY(c)+this.position.getBarWidthAt(c)/2;e.line(o,h,o,u).attr("style",`stroke: ${r}; stroke-width: ${Math.max(1,this.position.spacings.axisLineWidth)}px`),e.polygon(`${o},${h+.5*n} ${o-.25*n},${h} ${o+.25*n},${h}`).attr("style",`fill: ${r}`),i.label&&e.plain(i.label).attr({x:o,y:h-.3*n,"text-anchor":"middle"}).attr("style",`fill: ${r}`)}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 Cl(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new Cl(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new Cl(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new Cl(-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()===Al.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 oc{constructor(t=2,i=1,s){this.percent=t,this.decimal=i,this.percentSign=s}}class hc{adapt(t){const i=new oc,s=t=>R.isNumber(t)&&Number.isInteger(t)&&t>=0&&t<=100;return s(t.percent)&&(i.percent=t.percent),s(t.decimal)&&(i.decimal=t.decimal),!1===t.percentSign&&(i.percentSign=!1),i}default(){return new oc}}const ac=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:I.ASC},this.level=j.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.parentDimensions={width:0,height:0},l(this)}getDb(){return this.stores||(this.stores=u(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(),wi(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new rc(new se(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 Ol(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 se(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 Ol(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 rc(new se(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(Ql,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=ic({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(Ql,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Ql,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=M(t,this.tableName,this.filter);return this.measureScaleError=void 0,new Pl(new Dl,new st(new Tl),new Tl,new hc,t,i,(t=>{this.measureScaleError=yi(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,sums:this.sums,sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:this.scenarioLabelTop,hideScenarioName:this.hideScenarioName,referenceLine:this.referenceLine,italicCategories:this.italicCategories})}prepareStyle(){var t,i;const s=new Ul(new Gl,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};ac.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 lc=class{validateFilter(t){const i="ERR_filter";p(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(qt(t)||H(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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";rt(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)?this.errors.remove(i):"invalid"===ei(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";L(t)||ot(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";!T(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=K(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";L(t)||ht(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";q(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){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const s=`WARN_${t}`;!T(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(s)}validateTotals(t){const i="WARN_totals";L(t)||null!=this.parseTotals(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:'totals: needs JSON with a unitScaling greater than 0, by one of all, year, quarter, month, week, and aggregation one of sum, average, last. For example {"unitScaling":280}.'}),this.bindTotalsDataset()}parseTotals(t){var i,s;try{const e=JSON.parse(t),n=ei(null==e?void 0:e.unitScaling,this.pixelPerUnitGroupMap);if("value"!==n.kind||!(n.value>0))return null;const r=null!==(i=e.by)&&void 0!==i?i:"all",o=null!==(s=e.aggregation)&&void 0!==s?s:"sum";if(!["all","year","quarter","month","week"].includes(r))return null;if(!["sum","average","last"].includes(o))return null;const h=Number(e.width),a="string"==typeof e.label||"number"==typeof e.label?String(e.label):"";return{unitScaling:n.value,by:r,aggregation:o,label:a,width:h>0?h:1,dataset:"string"==typeof e.dataset?e.dataset.trim():""}}catch(t){return null}}bindTotalsDataset(){var t,i;let s;try{const i=L(this.totals)?"":null===(t=JSON.parse(this.totals))||void 0===t?void 0:t.dataset;s="string"==typeof i?i.trim():""}catch(t){s=""}this.element.isConnected&&s!==this.totalsDatasetName&&(null===(i=this.totalsDatasetUnsubscribe)||void 0===i||i.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName=s,s&&(this.totalsDatasetUnsubscribe=u(this.element).db.subscribe(s,(()=>{this.dataVersion++}))))}prepareTotals(){const t=L(this.totals)?null:this.parseTotals(this.totals),i="WARN_totals_unitScaling";if(null==t)return this.errors.remove(i),null;if("value"!==ei(this.unitScaling,this.pixelPerUnitGroupMap).kind)return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs a fixed unitScaling of the chart, the total columns are not drawn."}),null;if(this.hidesScenarios())return this.errors.addOrReplace({id:i,type:"warning",message:"totals: needs the columns of the chart, a chart with scenarios none draws no total columns."}),null;this.errors.remove(i);const{unitScaling:s}=t,e=function(t,i){var s={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(e=Object.getOwnPropertySymbols(t);n<e.length;n++)i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n])&&(s[e[n]]=t[e[n]])}return s}(t,["unitScaling"]);return Object.assign(Object.assign({},e),{pixelPerUnit:this.getEffectiveFontPx()/s})}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!T(t)||Number(t)<1?this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsStep: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateAxisTitlePosition(t){const i="WARN_axisTitlePosition";L(t)||["left","right","none"].includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisTitlePosition: invalid value '"+t+"' 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.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.dataFormatPercentSign=!0,this.axisLabelsStep=1,this.totals="",this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this._baseHeightBonus=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: ${lc.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${ni(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: ${lc.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),Zt(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=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),this.t=ti(this).t,this.resolveInherited=ri(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),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateAxisLabelsStep(this.axisLabelsStep),this.validateTotals(this.totals),this.validateAxisTitlePosition(this.axisTitlePosition)}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=Xt(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 _(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===ei(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=ii(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)`),_(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(){Bs(this.element,"bn-chart-time-renderer");const t=this.updateBaseHeightBonus();t&&!this._autoScaleGuard&&n(this);const{mode:i}=ii(this.scale);if("auto"!==i&&"empty"!==i)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,this.checkOverflow(),void(t&&n(this));const s=this.element,{width:e}=Xt(s);if(e<=0)return void this.checkOverflow();this._lastObservedWidth=e;const o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),h=s.scrollWidth,a=this.appliedScaleFactor;if(h<=e+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,a*(e-1)/h);Math.abs(l-a)<.01||(s.style.setProperty("--bn-font-size",o*l+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${l.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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}=Xt(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())}connectedCallback(){this.bindTotalsDataset()}disconnectedCallback(){var t,i;null===(t=this.totalsDatasetUnsubscribe)||void 0===t||t.call(this),this.totalsDatasetUnsubscribe=null,this.totalsDatasetName="",null===(i=this.layoutObserver)||void 0===i||i.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}updateBaseHeightBonus(){var t,i;const s=this.prepareSegments();let e=0;if("value"===ei(this.unitScaling,this.pixelPerUnitGroupMap).kind&&s.length>1&&0===s[0].length){const n=Array.from(null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer"))&&void 0!==i?i:[]);e=function(t,i){let s=0;for(const e of i)e>0&&(s+=t-e);return Math.max(0,s)}(this.segmentShare(this._lastAppliedHeight,s.length),n.slice(1).map((t=>t.offsetHeight)))}const n=function(t,i){const s=i-t;return s<-1||s>8?i:t}(this._baseHeightBonus,e);return n!==this._baseHeightBonus&&(this._baseHeightBonus=n,!0)}segmentShare(t,i){const s=this.showMeasureScale?this.getEffectiveFontPx():0;return Math.max(0,t-s)/Math.max(1,i)}prepareDimension(t=!1){const i=Xt(this.element),s=this.prepareScenarios(),e=this.prepareSegments();this.canvasWidthSegmented=i.width/(s.length+this.prepareVariances().length||1),this._lastAppliedHeight=i.height;const n=this.segmentShare(i.height,e.length);return{width:this.canvasWidthSegmented,height:n+(t?this._baseHeightBonus:0)}}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()));if(H(n.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return L(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())))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&H(t.value)}prepareSegments(){const t=this.hidesScenarios()?[]:[[]],i=new Map;for(const s of this.prepareVariances()){const e=new Xs(s),n=`${e.type}:${e.delta}`,r=this.scenarioSwitch&&e.isValid?i.get(n):void 0;if(r){r.push(s);continue}const o=[s];t.push(o),e.isValid&&i.set(n,o)}return t}prepareAxisTitlePosition(){var t;const i=null===(t=this.axisTitlePosition)||void 0===t?void 0:t.trim().toLowerCase();return"right"===i||"none"===i?i:"left"}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return L(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 Xs(i);if(t.isValid)for(const n of[t.base,t.delta])s.includes(n)||e.push(`'${i}' needs '${n}'`)}!this.hidesScenarios()&&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=g,i=new Map(["no-data","date-format-short-year"].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(),...ie(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=ei(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: ${lc.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=ei(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: ${lc.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){if(this.syncSpaceLeft>-1)return this.syncSpaceLeft;const s="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return Oa.getMaxWidthOfArrayItems([...s,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return L(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}`}),at[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?at.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),at[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 lt[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase().replace("-","_")]}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 L(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(L(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios",e="WARN_stack_scenarios_max",n=this.prepareScenarios();return i===Q.DIMENSIONS&&n.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${n[0]}" is used, the rest (${n.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s),i===Q.SCENARIOS&&n.length>4?this.errors.addOrReplace({id:e,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${n.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(e),{by:i,mode:t.mode||tt.ABSOLUTE,order:t.order||Z.DATASET,notation:"scenario"===t.notation?"scenario":"none",legend:["right","both","none"].includes(t.legend)?t.legend:"left",percentMark:!0===t.percentMark}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_scenarios_max"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?ct.LINE:"auto"===i?ct.AUTO:ct.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=Xt(this.element).width,o=this.preparePixelPerUnit(),h=this.preparePixelPerPercentage(),a=this.prepareStackConfig(),l=0===t.length,c=this.hidesScenarios()?qs(t):this.prepareScenarios(),u=l&&(null==a?void 0:a.by)===Q.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return i("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:u,variances:t.length>0?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(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal,percentSign:!1!==this.dataFormatPercentSign},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scalingIndicator:Number(this.scalingIndicator)||0,totals:this.prepareTotals(),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:r,parentDimensions:this.prepareDimension(l),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return rs(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=di(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=ws(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-time-renderer"),f={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:li(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:ai(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=ei(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=ei(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}=ii(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(){this.checkVarianceScenarios(this.prepareVariances());const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const e=this.getFontStyles();return i(s,{key:"1b6a2c72252e0f0c437815ea71652bc6ca7bb90c",style:e},i("div",{key:"1df2b96475b83b11c197a00efed98b2e60a05ed9",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}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],totals:[{validateTotals:0}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}}};lc.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 cc{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 uc{adapt(t){const i=new cc;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 cc}}class dc{constructor(t,i,s,e,n,r,o){this.categoryPosition={x:0,y:0},this.spacings=new cc,this.categoriesBoxOffset={width:0,height:0},this.slots=null,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*wa("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}setSlots(t){this.slots=t}slotOf(t){const i=this.slots;if(null==i||0===i.length)return t;const s=i.length-1;if(t<=0)return i[0]+t;if(t>=s)return i[s]+(t-s);const e=Math.floor(t);return i[e]+(i[e+1]-i[e])*(t-e)}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+this.slotOf(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 fc{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 vc{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 pc{constructor(t){this.container=new Eh,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()}}function gc(t,i,s){const e=t.root();if(!e)return null;const n=`pattern-hatch-${i}-${s}`.replace(/[^a-zA-Z0-9-]/g,"");return e.findOne(`#${n}`)||e.pattern(10,10,(t=>{t.rect(10,10).fill(s),t.line(0,5,5,0).stroke({width:1,color:i,linecap:"square"}),t.line(5,10,10,5).stroke({width:1,color:i,linecap:"square"})})).id(n)}class mc{constructor(t,i,s,e){this.percentClamp=mc.PERCENT_CLAMP,this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?Js(e,null,!0):e;this.variance="neg"===n||n===Sc.NEG?Sc.NEG:"pos"===n||n===Sc.POS?Sc.POS:Sc.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>this.percentClamp?this.percentClamp*this.pixelPerUnit:this.value<-this.percentClamp?-this.percentClamp*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Sc.NEU===this.variance?Sc.NEU:Sc.POS===this.variance?Sc.NEG:Sc.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>this.percentClamp}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}mc.PERCENT_CLAMP=1.45;class bc{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 yc{constructor(){}adapt(t){const i=new bc;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=w.fromISO(t,{zone:"utc"});if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' - skipping row`)}default(){return new bc}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 wc{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 xc{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 wc(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 vc(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new wc(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var Sc,$c;!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"}(Sc||(Sc={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}($c||($c={}));class Mc{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.titlePosition=t.titlePosition||"left",this.titleX=t.titleX,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){var s;null==i&&(i=""),"right"!==this.titlePosition?t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative)):t.text(i).addClass(this.CSS_AXIS_TITLE).move(null!==(s=this.titleX)&&void 0!==s?s:this.position.getAxisEndPositionX()+this.position.spacings.labelToColumn,this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&"none"!==this.titlePosition&&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 _c{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,e,n,r;if(this.isEmpty())return this;const o=this.getScenarioStyle();let h=this.convertToSVGStyle(o,"stroke"),a=this.getFillStyle(o);if(this.isVarianceColumn&&"pl"===this.dataPoint.notation){const t=Number(null===(e=null===(s=this.columnBarStyles)||void 0===s?void 0:s.pl)||void 0===e?void 0:e.width);h={color:(null==o?void 0:o.fill)||this.FALLBACK_COLOUR,width:t>0?t:1},a=this.styles.fontStyles.background||"#ffffff"}if(this.isVarianceColumn&&"fc"===this.dataPoint.notation){const t=(null==o?void 0:o.fill)||this.FALLBACK_COLOUR,i=gc(this.scenarioGroup,t,this.styles.fontStyles.background||"#ffffff");i&&(h={color:t,width:1},a=i)}this.scenarioGroup.attr(as(this.dataPoint.key)),null===(n=this.columnGroup)||void 0===n||n.attr(as(this.dataPoint.key,"element")),this.dataPoint.key&&Number.isFinite(this.dataPoint.value)&&(null===(r=this.columnGroup)||void 0===r||r.attr("data-bn-value",this.dataPoint.value)),null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(a,h):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(a).stroke(h).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=ka.Bottom;null!=t.value&&t.value<0&&(i=ka.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,ka.Center).setPoint(t.key)}getScenarioLabel(t){return new Ta(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,ka.Center,this.isPrimaryColumn?ka.Left:ka.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 kc{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(as(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(as(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 Ta(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,ka.Center,s?ka.Right:ka.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 Oc{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 Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,r?et:s.value,this.styles,ka.Center,ka.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(t={percent:2,decimal:1}){var i,s,e;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.dataLabel)||void 0===s||s.draw(!0,t),this;if(this.isEmpty())return this;this.scenarioGroup.attr(as(this.dataPoint.key)),this.barGroup.attr(as(this.dataPoint.key,"element"));const n=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const h=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),a=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),l=this.barStyles[this.dataPoint.getScenario()];if(null!=l&&l.fillpattern){const t=this.styles.pattern.get(l.fillpattern);null!=t&&(o=t.pattern)}if("pl"===this.dataPoint.notation&&(r.color=(null==n?void 0:n.fill)||r.color,r.width=Math.max(1,Number(r.width)||0),o=this.styles.fontStyles.background||"#ffffff"),this.dimensions.clipped)this.createClippedNeedleHead(o,r);else if("fc"===this.dataPoint.notation){const t=gc(this.barGroup,h.color,this.styles.fontStyles.background||"#ffffff");this.createNeedleHead(null!=t?t:h,{color:h.color,width:1})}else this.createNeedleHead(h,a);this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(o).stroke(r),null===(e=this.dataLabel)||void 0===e||e.draw(!0,t)}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}}class Nc{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 xi[e]||xi.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(as(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?[Pa.Below,Pa.Left,Pa.Right,Pa.Above]:[Pa.Above,Pa.Left,Pa.Right,Pa.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=ka.Bottom,c=ka.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 Ta(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 Ta(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,ka.Center,ka.Left).forceStringTypeDraw()}}class Ac{constructor(t,i,s,e,n,r,o,h,a,l,c,u=!1,d=!1){this.notation=u,this.plainShares=d,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){var s,e;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const n=this.dataPoint.value,r=this.dataPoint.pixelPerUnit,o=this.position.getColumnPositionY(),h=Math.abs(this.segment.end-this.segment.start)*r,a=o-Math.max(this.segment.start,this.segment.end)*r,l=this.position.getColumnCenterPositionX(this.index),c=this.position.getColumnWidth(),u=this.styles.stackColors;let d=u[this.segmentIndex%u.length],f={color:d},v={color:d,width:.5},p=!1;const g=Sa(null!==(s=this.dataPoint.scenario)&&void 0!==s?s:"");if(this.notation&&("fc"===g||"pl"===g)){const t=this.styles.barStyles.getSVGStyle(g);0===this.segmentIndex&&(d=t.fill),f={color:d},v={color:t.stroke,width:1},"hatched"===t.fillpattern&&(p=!0,f=null!==(e=this.hatchPattern(d,t.stroke))&&void 0!==e?e:f)}if(this.columnGroup.attr(as(this.dataPoint.key,"element")),this.columnGroup.attr("data-bn-value",n),this.columnGroup.rect(c,Math.max(h,.5)).fill(f).stroke(v).y(a).cx(l),h>=Math.min(18,1.15*(this.styles.fontStyles.size||18))){const s=a+h/2,e=t=>p?t:t.setSegmentFill(d);if(this.stackMode===tt.RELATIVE||this.stackMode===tt.ABSOLUTE_RELATIVE){const i=this.plainShares?Oa.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):Oa.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);e(new Ta(this.group,l,s,"STACK_SEG",i,this.styles,ka.Center,ka.Center)).setPoint(this.dataPoint.key).forceStringTypeDraw()}else e(new Ta(this.group,l,s,"STACK_SEG",n,this.styles,ka.Center,ka.Center)).setPoint(this.dataPoint.key).draw(!0,t,i)}}hatchPattern(t,i){const s=this.group.root();if(!s)return null;const e=`pattern-stack-fc-${this.segmentIndex}`;return s.findOne(`#${e}`)||s.pattern(10,10,(s=>{s.rect(10,10).fill(t),s.line(0,5,5,0).stroke({width:1,color:i,linecap:"square"}),s.line(5,10,10,5).stroke({width:1,color:i,linecap:"square"})})).id(e)}drawTotalLabel(t={percent:2,decimal:1},i=new La,s){if(this.stackMode===tt.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 Ta(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,e?ka.Top:ka.Bottom,ka.Center).setPoint(s,"total").draw(!0,t,i)}}const Rc=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class Lc{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=Si[s]||Si.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,Rc.length-1);t=Rc[s].fill,i=Rc[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=Si[s]||Si.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 Tc{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=ka.Bottom;return null!=t.value&&t.value<0&&(i=ka.Top),new Ta(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,ka.Center)}getScenarioLabel(t){return new Ta(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,ka.Bottom,ka.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 Ec{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 Tc(this.position,this.styles,i,s,e,!1,n,o).updateLabelGroup(r)}createPrimaryBar(t,i,s=!0){const e=this.svgGroups.scenario1.group().id(""+i),n=this.svgGroups.scenario1Label.group().id(""+i);let r=null;return s&&this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new _c(this.position,this.styles,t,i,!0,e,r,this.overflowConfig).updateLabelGroup(n)}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 _c(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 Oc(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i,s=!0){const e=this.svgGroups.scenario2.group().id(""+i);let n=null;return s&&this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new _c(this.position,this.styles,t,i,!1,e,n,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 kc(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 kc(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 Nc(this.position,this.styles,t,e,n,i,r,this.i18n,this.collisionManager,s)}}const Pc="bn-measurement-host";function Cc(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(Pc);return t||(t=document.createElement("div"),t.id=Pc,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 Wc,Dc;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Wc||(Wc={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Dc||(Dc={}));const zc="#c5dbf2";class Uc{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 mc(0,Sc.AC1,1,Sc.NEU),this.highestDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.smallestVarianceDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.highestVarianceDataPointValue=new mc(0,Sc.AC1,1,Sc.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Sc.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=Wc.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=at.DAY,this.locale="de",this.axisLabelsMode=lt.SMART,this.intervalSpanLimit=32,this.measureScale=new La,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=ct.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.axisLabelsStep=1,this.scalingIndicator=0,this.totals=null,this.totalColumns=[],this.totalVariances=[],this.highestColumnDataPointValue=new mc(0,"default",0,Sc.NEU),this.highestPeriodVarianceDataPointValue=new mc(0,"default",0,Sc.NEU),this.scenarioSwitch=!1,this.axisTitlePosition="left",this.varianceOverlaps=0,this.db=i,this.tableName=s,this.ruleSet=t||new se,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 se}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===ct.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestPeriodVarianceDataPointValue:this.highestColumnDataPointValue).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+this.switchNamesHeight())-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,s,e,n,r,o,h;this.state=Wc.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const a=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.axisLabelsStep=null!==(i=t.axisLabelsStep)&&void 0!==i?i:1,this.scalingIndicator=null!==(s=t.scalingIndicator)&&void 0!==s?s:0,this.totals=null!==(e=t.totals)&&void 0!==e?e:null,this.scenarioSwitch=null!==(n=t.scenarioSwitch)&&void 0!==n&&n,this.axisTitlePosition=null!==(r=t.axisTitlePosition)&&void 0!==r?r:"left",this.dateInterval=this.findDateInterval(t.dateInterval),this.stackConfig=t.stackConfig,this.dataModel=this.populateModel(a,this.dateInterval),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(o=null==t?void 0:t.variances)&&void 0!==o?o:[],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=a,null!=this.stackConfig){const t=[];for(const i of this.dataModel)t.push(...this.stackGroups(i).map((t=>t.layout)));const i=ec(t),{reference:s}=this.seriesSlots();if(s)for(const t of this.dataModel){const e=null===(h=t[s])||void 0===h?void 0:h.value;Number.isFinite(e)&&(i.positive=Math.max(i.positive,e),i.negative=Math.max(i.negative,-e))}const{scenario:e,variance:n}=this.highestDataPointValue;this.highestDataPointValue=new mc(i.positive,e,this.pixelPerUnit,n),this.smallestDataPointValue=new mc(0-i.negative,e,this.pixelPerUnit,n)}this.highestColumnDataPointValue=this.highestDataPointValue,this.highestPeriodVarianceDataPointValue=this.highestVarianceDataPointValue,this.totalColumns=this.computeTotalColumns(),this.totalVariances=this.computeTotalVariances();for(const t of this.totalVariances)null!=t&&Number.isFinite(t.value)&&(t.value>Number(this.highestVarianceDataPointValue.value)&&(this.highestVarianceDataPointValue=t),t.value<Number(this.smallestVarianceDataPointValue.value)&&(this.smallestVarianceDataPointValue=t));if(this.hasScalingIndicator()&&this.scalingIndicator>Number(this.highestDataPointValue.value)){const{scenario:t,variance:i}=this.highestDataPointValue;this.highestDataPointValue=new mc(this.scalingIndicator,t,this.pixelPerUnit,i)}const l=this.isVarianceChart()?0:this.totalsHeight();if(l>this.highestDataPointValue.getScaledUnit()&&this.pixelPerUnit>0){const{scenario:t,variance:i}=this.highestDataPointValue;this.highestDataPointValue=new mc(l/this.pixelPerUnit,t,this.pixelPerUnit,i)}this.updateTitle(),this.updatePosition(a)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Oa.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,i,s;let e=this.scenarioSwitch?null===(t=this.configVariances)||void 0===t?void 0:t[0]:null===(i=this.configVariances)||void 0===i?void 0:i.toString();if(this.scenarioSwitch&&e){const t=new Xs(e),i=null===(s=this.dataModel)||void 0===s?void 0:s[0],n=["scenario1","scenario2","scenario3","scenario4"].find((s=>{var e;return(null===(e=null==i?void 0:i[s])||void 0===e?void 0:e.scenario)===t.base}));t.isValid&&null!=n&&("scenario1"===n||this.followerSlots().includes(n))&&(e=`${t.type}ac1_${t.delta}_${t.direction}`)}this.title=this.configTitle||Oa.translateScenarioLabel(e,this.i18n)}setSource(t){var i,s;if(this.state=Wc.DIRTY,this.queryError=void 0,this.fromExpr=M(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=yi(t))}getAllocatedCanvasWidth(){var t;const i=this.position.getAxisEndPositionX(),s=3*this.styles.fontStyles.size,e=Math.max(this.axisCategoryArea.width,this.scenariosArea.width),n=e>0?e+this.position.leftSideLabelLength:0;let r=0;if("right"===this.axisTitlePosition&&this.title){const s=wa(this.title,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;r=(null!==(t=this.rightTitleX())&&void 0!==t?t:i+this.position.spacings.labelToColumn)+s+this.styles.padding.right}const o=this.legendWidth("right"),h=o>0?i+this.position.spacings.labelToColumn+o+this.styles.padding.right:0;let a=0;if(this.hasScalingIndicator()){const t=wa(this.scalingIndicatorText(),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;a=this.scalingIndicatorLabelX()+t+this.styles.padding.right}const l=this.hasEndTotal()?this.totalGeometry(0).right+this.endTotalTextWidth()+this.styles.padding.right:0;return Math.max(i+s,n,r,h,a,l)}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===Dc.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)+this.switchNamesHeight()}switchNamesHeight(){return!this.hideAxisLabels&&this.contextRow().length>0?this.position.dataLabelHeight:0}parentPeriodLabel(t){if(this.axisLabelsMode!==lt.TWO_ROW||null==t||!t.isValid)return"";switch(this.dateInterval){case at.MONTH:case at.QUARTER:return t.setLocale(this.locale).toFormat("yyyy");case at.WEEK:return t.setLocale(this.locale).toFormat("kkkk");case at.DAY:return t.setLocale(this.locale).toFormat("LLL yyyy");default:return""}}contextRow(){const t=this.switchRuns();if(this.axisLabelsMode!==lt.TWO_ROW)return t.map((t=>({from:t.from,to:t.to,text:Oa.translateScenarioLabel(t.scenario,this.i18n),scenario:t.scenario})));if(!this.isVarianceChart()&&this.determineEffectiveChartMode()!==ct.BAR)return[];const i=this.isVarianceChart()?this.variancesDataModel:this.dataModel,s=[];let e="";return i.forEach(((i,n)=>{var r;const o=t.find((t=>t.from===n)),h=this.parentPeriodLabel(i.date),a=[];""!==h&&h!==e&&a.push(h),e=h,o&&a.push(Oa.translateScenarioLabel(o.scenario,this.i18n)),a.length>0&&s.push({from:n,to:n,text:a.join(" "),scenario:null!==(r=null==o?void 0:o.scenario)&&void 0!==r?r:"parent"})})),s}static hasValue(t){return null!=t&&!t.isEmpty()&&null!=t.value&&!Number.isNaN(t.value)}static hasAmount(t){return null!=t&&Number.isFinite(t.value)&&0!==t.value}followerSlots(){return!this.scenarioSwitch||null!=this.stackConfig&&this.stackConfig.by!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR?[]:["scenario2","scenario3","scenario4"].filter((t=>{let i=0;for(const s of this.dataModel)if(Uc.hasValue(s[t])){if(Uc.hasValue(s.scenario1))return!1;i++}return i>0}))}visibleSlot(t,i){var s;return Uc.hasValue(t.scenario1)?"scenario1":null!==(s=i.find((i=>Uc.hasValue(t[i]))))&&void 0!==s?s:null}switchRuns(){if(!this.scenarioSwitch||null!=this.stackConfig&&this.stackConfig.by!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR)return[];const t=this.followerSlots();if(0===t.length&&1!==this.scenarioPropOrder.length)return[];const i=[];return this.dataModel.forEach(((s,e)=>{const n=this.visibleSlot(s,t),r=n?s[n].scenario:null,o=i[i.length-1];null!=r&&(null==o?void 0:o.scenario)!==r?i.push({scenario:r,from:e,to:e}):o&&(o.to=e)})),i}seriesSlots(){var t,i,s;if(!this.scenarioSwitch||(null===(t=this.stackConfig)||void 0===t?void 0:t.by)!==Q.DIMENSIONS||this.determineEffectiveChartMode()!==ct.BAR)return{fill:[],reference:null};const e=this.followerSlots(),n=t=>Uc.hasAmount(t),r=[];let o=null;for(const t of["scenario2","scenario3","scenario4"]){if(e.includes(t))continue;let h=0,a=!1;for(const r of this.dataModel){const o=null!==(i=this.visibleSlot(r,e))&&void 0!==i?i:"scenario1";for(const i of null!==(s=r.series)&&void 0!==s?s:[])n(i.points[t])&&(h++,a=a||n(i.points[o]))}0!==h&&(a?null==o&&this.stackConfig.mode!==tt.RELATIVE&&(o=t):r.push(t))}return{fill:r,reference:o}}getIgnoredSwitchScenarios(){var t;if(!this.scenarioSwitch||(null===(t=this.stackConfig)||void 0===t?void 0:t.by)!==Q.DIMENSIONS||this.isVarianceChart())return[];const i=this.followerSlots(),{fill:s,reference:e}=this.seriesSlots(),n=[...i,...s,e];return["scenario2","scenario3","scenario4"].filter((t=>!n.includes(t)&&this.dataModel.some((i=>Uc.hasValue(i[t]))))).map((t=>{var i;return null===(i=this.dataModel.find((i=>{var s;return null!=(null===(s=i[t])||void 0===s?void 0:s.scenario)})))||void 0===i?void 0:i[t].scenario}))}getVarianceOverlaps(){return this.varianceOverlaps}fitRelativeVariances(t){const i=this.variancesDataModel.filter((t=>t.type===Dc.RELATIVE)).map((t=>t.scenario1));if(i.length>0&&i.push(...this.totalVariances.filter((t=>null!=t))),0===i.length||!i.some((t=>t.isClipped())))return;const s=t=>{i.forEach((i=>i.percentClamp=t)),this.updatePosition(this.lastScenarios)};s(Number.POSITIVE_INFINITY),this.layout(),t>0&&this.getAllocatedCanvasHeight()<=t||s(mc.PERCENT_CLAMP)}getUnitBarExtent(){var t,i;const s=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===Dc.RELATIVE)),e=this.isVarianceChart(),n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Zl({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 tc({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===Dc.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 Eh;Cc(t,(()=>this.draw(t)))}toString(){const t=new Eh;return Cc(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===Wc.DIRTY&&(this.state=Wc.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawTotalVariances(t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===ct.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.drawScalingIndicator(t)):this.determineEffectiveChartMode()===ct.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),this.drawScalingIndicator(t),this.drawTotalColumns(t))}hasScalingIndicator(){var t,i;return this.scalingIndicator>0&&!this.isVarianceChart()&&(null!==(t=this.configVariances)&&void 0!==t?t:[]).every((t=>!t))&&this.determineEffectiveChartMode()===ct.BAR&&(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)!==tt.RELATIVE}scalingIndicatorText(){var t,i,s;const e=null!==(i=null===(t=this.dataFormatDigits)||void 0===t?void 0:t.decimal)&&void 0!==i?i:1;return Oa.number(this.scalingIndicator,"decimal",e,e,(null===(s=this.measureScale)||void 0===s?void 0:s.value)||1,this.styles.locale)}scalingIndicatorTextWidth(){return wa(this.scalingIndicatorText(),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}scalingIndicatorLabelX(){const t=this.position.spacings.labelToColumn,i=this.position.getColumnWidth()/2+this.position.spacings.scenarioOffset;let s=this.position.getColumnCenterPositionX(Math.max(0,this.dataModel.length-1))+i;this.hasTotals()&&!this.hasEndTotal()&&(s=Math.max(s,this.totalGeometry(this.totalColumns.length-1).right));const e=this.legendWidth("right");return s+t+(e>0?e+t:0)}scalingIndicatorBand(){if(!this.hasScalingIndicator()||0===this.dataModel.length)return null;const t=this.position.getColumnWidth()/2+this.position.spacings.scenarioOffset,i=this.scalingIndicator*this.pixelPerUnit;return this.overflowConfig&&i>this.overflowConfig.cutHeight?null:{left:this.position.getColumnCenterPositionX(0)-t,right:this.position.getColumnCenterPositionX(this.dataModel.length-1)+t,height:i}}drawScalingIndicator(t){const i=this.scalingIndicatorBand();if(null==i)return;const{left:s,right:e,height:n}=i,r=this.position.getColumnPositionY(),o=t.group().id("ScalingIndicator"),h=this.position.getColumnWidth()/2+this.position.spacings.scenarioOffset,a=this.hasTotals()&&!this.hasEndTotal()?this.totalRuns().map((t=>({left:this.position.getColumnCenterPositionX(t.from)-h,right:this.position.getColumnCenterPositionX(t.to)+h}))):[{left:s,right:e}];for(const t of a)o.rect(t.right-t.left,n).x(t.left).y(r-n).fill(zc);o.back(),new Ta(t.group().id("ScalingIndicatorLabel"),this.scalingIndicatorLabelX(),r-n,"SCALING_INDICATOR",this.scalingIndicatorText(),this.styles,ka.Center,ka.Left).forceStringTypeDraw()}rightTitleX(){if(this.hasEndTotal())return this.totalGeometry(0).right+this.endTotalTextWidth()+this.position.spacings.labelToColumn}hasTotals(){return this.totalColumns.length>0}hasEndTotal(){return this.hasTotals()&&"all"===this.totals.by}totalIndex(t){return this.dataModel.length+1+t}totalGeometry(t){var i,s;const e=this.position.getColumnWidth()*(null!==(s=null===(i=this.totals)||void 0===i?void 0:i.width)&&void 0!==s?s:1),n=this.position.getColumnCenterPositionX(this.totalIndex(t)),r=this.position.spacings.scenarioOffset;return{center:n,width:e,left:n-e/2-2*r,right:n+e/2+r}}totalSlots(t,i,s,e){var n,r,o;const h=this.dataModel.length,a=i>0?((null!==(r=null===(n=this.totals)||void 0===n?void 0:n.width)&&void 0!==r?r:1)-1)*t/i:0,l=[],c=[];if("all"===this.totals.by){for(let t=0;t<h;t++)l.push(t);const t=this.scalingIndicator>0&&i>0?(this.scalingIndicatorTextWidth()+e*s)/(i*s):0;return c.push(h+1+a/2+t),{slots:[...l,h,...c],axisColumns:h}}const u=this.followerSlots(),d=u.includes(null!==(o=this.visibleSlot(this.dataModel[h-1],u))&&void 0!==o?o:"scenario1"),f=!u.includes("scenario4")&&this.dataModel.some((t=>Uc.hasValue(t.scenario4))),v=d&&!f?0:1;let p=0,g=0;for(let t=0;t<h;t++){l.push(t+p);const i=this.totalColumns[g];if(null!=i&&i.to===t){const i=t===h-1?v:0;c.push(t+p+i+1+a/2),p+=i+1+a,g++}}return{slots:[...l,h+p,...c],axisColumns:h+p}}totalRuns(){const t=[];let i=0;for(const s of this.totalColumns)t.push({from:i,to:s.to}),i=s.to+1;return i<this.dataModel.length&&t.push({from:i,to:this.dataModel.length-1}),t}totalGroupStart(t){var i,s;const e=null!==(s=null===(i=this.totals)||void 0===i?void 0:i.by)&&void 0!==s?s:"all";return"all"!==e&&null!=t&&t.isValid?t.startOf(e):null}totalLabel(t){var i,s;if(null==t)return null!==(s=null===(i=this.totals)||void 0===i?void 0:i.label)&&void 0!==s?s:"";const e={year:at.YEAR,quarter:at.QUARTER,month:at.MONTH,week:at.WEEK}[this.totals.by];return this.createDateFactory().getShortDateString(t,e)}seriesSlotKeys(){return["scenario1",...this.followerSlots()]}referenceSlot(){const t=this.followerSlots();for(const i of["scenario2","scenario3","scenario4"])if(!t.includes(i)&&this.dataModel.some((t=>{var s;return Number.isFinite(null===(s=t[i])||void 0===s?void 0:s.value)})))return i;return null}mixedScenario(t){var i,s;return null!==(s=null!==(i=t.find((t=>"fc"===Sa(t))))&&void 0!==i?i:t.find((t=>"pl"===Sa(t))))&&void 0!==s?s:t[0]}totalDatasetRows(){var t,i,s,e;const n=null===(t=this.totals)||void 0===t?void 0:t.dataset;if(!n)return null;const r=M(this.db,n,""),o=new Map;if(!r)return o;let h;try{h=this.db.exec(`SELECT * FROM ${r}`)}catch(t){return this.failQuery(t),o}for(const t of h){const n=Uc.parseDate(t.date),r=n?this.totalGroupStart(n):null,h=r&&null!==(i=r.toISODate())&&void 0!==i?i:"";if("all"!==this.totals.by&&""===h)continue;const a=null!==(s=o.get(h))&&void 0!==s?s:{};for(const[i,s]of Object.entries(t)){const t="string"==typeof s&&""!==s.trim()?Number(s):s;"date"!==i&&"number"==typeof t&&Number.isFinite(t)&&(a[i]=(null!==(e=a[i])&&void 0!==e?e:0)+t)}o.set(h,a)}return o}static parseDate(t){if(t instanceof Date)return w.fromJSDate(t,{zone:"utc"});if("string"==typeof t){const i=w.fromISO(t,{zone:"utc"});return i.isValid?i:null}return"number"==typeof t?w.fromMillis(t,{zone:"utc"}):null}computeTotalColumns(){var t,i,s,e,n;if(null==this.totals||null!=this.stackConfig||0===this.dataModel.length||this.determineEffectiveChartMode()!==ct.BAR)return[];const r=this.followerSlots(),o=this.seriesSlotKeys(),h=this.referenceSlot(),a=h?null===(t=this.dataModel.find((t=>{var i;return null!=(null===(i=t[h])||void 0===i?void 0:i.scenario)})))||void 0===t?void 0:t[h].scenario:null,l=this.totalDatasetRows(),c=[];if(this.dataModel.forEach(((t,i)=>{const s=this.totalGroupStart(t.date),e=c[c.length-1];null!=e&&(null==s||null!=e.start&&+e.start==+s)?e.to=i:c.push({from:i,to:i,start:s})})),"all"!==this.totals.by&&c.length===this.dataModel.length&&c.length>1)return[];const u=[];for(const t of c){const c=this.dataModel.slice(t.from,t.to+1);let d=[],f=null,v=[];if(null!=l){const n=null!==(s=l.get(t.start&&null!==(i=t.start.toISODate())&&void 0!==i?i:""))&&void 0!==s?s:{};for(const t of o){const i=null===(e=this.dataModel.find((i=>{var s;return null!=(null===(s=i[t])||void 0===s?void 0:s.scenario)})))||void 0===e?void 0:e[t].scenario;null!=i&&Number.isFinite(n[i])&&0!==n[i]&&d.push({scenario:i,value:n[i]})}null!=a&&Number.isFinite(n[a])&&(f={scenario:a,value:n[a]})}else{const t=c.filter((t=>{var i;const s=this.visibleSlot(t,r);return null!=s&&Number.isFinite(null===(i=t[s])||void 0===i?void 0:i.value)}));v=t.map((t=>this.dataModel.indexOf(t)));const i=t.map((t=>t[this.visibleSlot(t,r)])),s="last"===this.totals.aggregation?t.slice(-1):t,e=h?s.map((t=>t[h])).filter((t=>Number.isFinite(null==t?void 0:t.value))):[],o=e.length===s.length?e:[],l=t=>t.reduce(((t,i)=>t+i.value),0);if("sum"===this.totals.aggregation){const t=new Map;for(const s of i)t.set(s.scenario,(null!==(n=t.get(s.scenario))&&void 0!==n?n:0)+s.value);d=[...t.entries()].map((([t,i])=>({scenario:t,value:i}))),o.length>0&&(f={scenario:a,value:l(o)})}else if(i.length>0){const t="last"===this.totals.aggregation;d=[{scenario:t?i[i.length-1].scenario:this.mixedScenario(i.map((t=>t.scenario))),value:t?i[i.length-1].value:l(i)/i.length}],o.length>0&&(f={scenario:a,value:t?o[o.length-1].value:l(o)/o.length})}}if(0===d.length)continue;if(d.some((t=>!(t.value>0))))return[];const p=d.reduce(((t,i)=>t+i.value),0);u.push(Object.assign(Object.assign({},t),{label:this.totalLabel(t.start),parts:d,total:p,reference:f,counted:v}))}return u}totalsHeight(){if(!this.hasTotals())return 0;const t=this.hasScalingIndicator()?this.scalingIndicator:0,i=Math.max(...this.totalColumns.map((t=>{var i,s;return Math.max(t.total,null!==(s=null===(i=t.reference)||void 0===i?void 0:i.value)&&void 0!==s?s:0)})));return Math.max(i,t)*this.totals.pixelPerUnit}computeTotalVariances(){var t,i;if(!this.hasTotals()||!this.isVarianceChart())return[];const s=null!==(t=this.dataModel[0])&&void 0!==t?t:null,e=(null!==(i=this.configVariances)&&void 0!==i?i:[]).map((t=>({name:t,variance:new Xs(t)}))).filter((t=>t.variance.isValid));if(0===e.length)return[];const n=e[0].variance,r=n.type===Dc.RELATIVE,o=this.totalDatasetRows(),h=this.totals.aggregation;return this.totalColumns.map((t=>{var i,a,l,c,u,d;let f,v;const p=new Set;if(null!=o){f=0;const s=null!==(a=o.get(t.start&&null!==(i=t.start.toISODate())&&void 0!==i?i:""))&&void 0!==a?a:{};for(const t of new Set(e.map((t=>t.variance.base))))Number.isFinite(s[t])&&0!==s[t]&&(f+=s[t],p.add(t.slice(0,2)));if(0===p.size||!Number.isFinite(s[n.delta]))return null;v=s[n.delta]}else{const i=("last"===h?t.counted.slice(-1):t.counted).map((t=>this.dataModel[t])),n=[];for(const t of i)for(const{variance:i}of e){const e=this.mapScenarios(i,s),r=null===(c=t[null!==(l=e.get(i.base))&&void 0!==l?l:""])||void 0===c?void 0:c.value,o=null===(d=t[null!==(u=e.get(i.delta))&&void 0!==u?u:""])||void 0===d?void 0:d.value;if(Number.isFinite(r)&&Number.isFinite(o)){n.push({base:r,delta:o,notation:i.base.slice(0,2)});break}}if(0===n.length||n.length!==i.length)return null;const r="average"===h?n.length:1;f=n.reduce(((t,i)=>t+i.base),0)/r,v=n.reduce(((t,i)=>t+i.delta),0)/r,n.forEach((t=>p.add(t.notation)))}const g=new mc(r?nt(f-v,v):f-v,n.delta,r?this.pixelPerPercentage:this.pixelPerUnit,n.direction);return this.scenarioSwitch&&(g.notation=p.has("fc")?"fc":1===p.size?[...p][0]:"ac"),g.key=this.totalKey(t,e[0].name),g}))}totalKey(t,i){const s={row:"total"};return null!=t.start&&(s.date=Uc.pointDate(t.start)),i&&(s.scenario=i),s}endTotalTextWidth(){if(!this.hasEndTotal())return 0;const t=t=>wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,i=this.position.spacings.labelToColumn,s=this.totalColumns[0].parts;return(!this.isVarianceChart()&&s.length>1?i+Math.max(...s.map((i=>t(this.scenarioName(i.scenario))))):0)+(this.hasScalingIndicator()?i+t(this.scalingIndicatorText()):0)}scenarioName(t){return this.i18n.get(t)||t}columnLook(t){var i,s;const e=null!==(i=this.scenarioStyles().barStyles[Sa(t)])&&void 0!==i?i:{},n=e.fillpattern?null===(s=this.styles.pattern.get(e.fillpattern))||void 0===s?void 0:s.pattern:void 0,r=e.fill||"#404040";return{fill:null!=n?n:r,stroke:{color:e.stroke||r,width:Number(e.width)||0},solid:n?null:r}}drawTotalAxis(t,i){const{left:s,right:e}=this.totalGeometry(0),n=null==this.axisScenario?"default":`${this.axisScenario}`.slice(0,2);t.line(s,i,e,i).addClass("axis-"+n)}drawTotalColumns(t){if(!this.hasTotals()||this.isVarianceChart())return;const i=this.totals.pixelPerUnit,s=this.position.getColumnPositionY(),e=this.position.spacings.labelToColumn,n=this.hasEndTotal(),r=t.group().id("TotalColumn"),o=t.group().id("TotalColumnLabels");this.totalColumns.forEach(((t,h)=>{const{center:a,width:l,left:c,right:u}=this.totalGeometry(h);if(this.hasScalingIndicator()){const t=this.scalingIndicator*i,o=this.scalingIndicatorBand();if(r.rect(u-c,t).x(c).y(s-t).fill(zc).back(),n&&null!=o){const i=this.scalingIndicatorLabelX()+this.scalingIndicatorTextWidth()+e/2;r.line(Math.min(i,c),s-o.height,c,s-t).stroke({color:"#5b9bd5",width:1}).id("ScalingIndicatorLink")}}if(null!=t.reference&&t.reference.value>0){const e=this.columnLook(t.reference.scenario),n=t.reference.value*i;r.rect(l,n).cx(a-this.position.spacings.scenarioOffset).y(s-n).fill(e.fill).stroke(e.stroke).attr(as(this.totalKey(t,t.reference.scenario),"element")).attr("data-bn-value",t.reference.value)}let d=s;for(const h of t.parts){const c=this.columnLook(h.scenario),u=h.value*i;d-=u;const f=this.totalKey(t,h.scenario);if(r.rect(l,u).cx(a).y(d).fill(c.fill).stroke(c.stroke).attr(as(f,"element")).attr("data-bn-value",h.value),t.parts.length>1){if(u>=this.position.dataLabelHeight){const t=new Ta(o,a,d+u/2,"TOTAL_PART",h.value,this.styles,ka.Center,ka.Center).setPoint(f);(c.solid?t.setSegmentFill(c.solid):t).draw(!0,this.dataFormatDigits,this.measureScale)}n&&new Ta(o,a+l/2+e,Math.max(d+u/2,s-t.total*i+this.position.dataLabelHeight/2),"TOTAL_NAME",this.scenarioName(h.scenario),this.styles,ka.Center,ka.Left).forceStringTypeDraw()}}new Ta(o,a,d-e,"TOTAL",t.total,this.styles,ka.Bottom,ka.Center).setPoint(this.totalKey(t),"total").draw(!0,this.dataFormatDigits,this.measureScale),!1===this.hideAxisLabels&&t.label&&new Ta(o,a,this.position.getAxisPositionY(!1)+this.position.spacings.labelToAxis,"TOTAL_LABEL",t.label,this.styles,ka.Top,ka.Center).forceStringTypeDraw()})),n&&(this.drawTotalAxis(r,this.position.getAxisPositionY(!1)),this.hasScalingIndicator()&&new Ta(o,this.totalGeometry(0).right+this.endTotalTextWidth()-this.scalingIndicatorTextWidth(),s-this.scalingIndicator*i,"SCALING_INDICATOR_TOTAL",this.scalingIndicatorText(),this.styles,ka.Center,ka.Left).forceStringTypeDraw())}drawTotalVariances(t){var i;if(!this.totalVariances.some((t=>null!=t)))return;const s=null!==(i=t.findOne("#Scenarios"))&&void 0!==i?i:t.group().id("Scenarios"),e=s.group().id("TotalColumn"),n=s.group().id("TotalColumnLabels"),r=this.variancesDataModel.some((t=>t.type===Dc.RELATIVE));this.totalVariances.forEach(((t,i)=>{if(null==t)return;const s=this.totalIndex(i);if(r)return void new Oc(this.position,this.scenarioStyles(),t,s,e.group()).updateLabelGroup(n.group()).draw(this.dataFormatDigits);const o=this.overflowConfig?Object.assign(Object.assign({},this.overflowConfig),{maxOverflow:Math.max(this.overflowConfig.maxOverflow,t.getScaledUnit()-(this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset))}):null;new _c(this.position,this.scenarioStyles(),t,s,!0,e.group(),null,o).updateLabelGroup(n.group()).setAsVariance().draw(this.dataFormatDigits,this.measureScale)})),this.hasEndTotal()&&this.drawTotalAxis(e,this.position.getAxisPositionY(r));const o=s.bbox();this.scenariosArea={height:o.height+this.styles.padding.top+this.styles.padding.bottom,width:o.width+this.position.spacings.columnWidth}}determineEffectiveChartMode(){return this.chartMode===ct.LINE||this.chartMode===ct.AUTO&&this.dataModel.length>this.maxBars?ct.LINE:ct.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=Wc.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){var i,s;let e;const n=wa(t.filter(((t,i)=>1===i||2===i)).map((t=>Oa.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,r=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let o,h;if(e=n>r?n:r,null!=this.position&&(e+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(e=this.leftSideOffsetForHorizontalSync),e=Math.max(e,this.legendWidth("left")),this.isVarianceChart()?(o=this.smallestVarianceDataPointValue,h=this.highestVarianceDataPointValue):(o=this.smallestDataPointValue,h=this.highestDataPointValue),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig,e=Math.max(t+i+s,this.isVarianceChart()?0:this.totalsHeight());h=new mc(e,h.scenario,1,h.variance)}let a=this.styles.scaleFactors;const l=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&l===ct.LINE){const t=this.styles.fontStyles.size,i=this.styles.padding,s=this.styles.scaleFactors,n=this.availableWidth-(i.left+i.right+t*s.scenarioOffset+e+t*s.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*s.columnWidth),e=new cc;Object.assign(e,s),e.categoryWidth=i,a=e}}const c=this.hasTotals()?this.totalSlots(a.columnWidth,a.categoryWidth,this.styles.fontStyles.size,a.scenarioOffset):null,u=new dc(new fc(this.styles.padding),a,this.styles.fontStyles,o,h,null!==(i=null==c?void 0:c.axisColumns)&&void 0!==i?i:this.dataModel.length,e);return u.setSlots(null!==(s=null==c?void 0:c.slots)&&void 0!==s?s:null),u}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=wa(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}scenarioStyles(){const t=te(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=Sc.AC1;if(null!=t&&t.length>0){const s=new Xs(t.toString());s.isValid&&(i=Zs(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=Sc.AC1),i}populateModel(t,i){var s;if(0===this.rowCount||!this.fromExpr)return[];let e=this.queryDataSet(i,"","");this.detectNaNCells(t,e),e=this.leftOuterJoinDates(e,i);const n=this.createDataRows(e,t);return(null===(s=this.stackConfig)||void 0===s?void 0:s.by)===Q.DIMENSIONS&&this.populateSeries(n,t,i),n}populateSeries(t,i,s){const e=this.queryDataSet(s,", [category]",", [category]");this.detectNaNCells(i,e);const n=t=>null==t.category?"":String(t.category),r=t=>{var i,s;return null!==(s=null===(i=null==t?void 0:t.toMillis)||void 0===i?void 0:i.call(t))&&void 0!==s?s:Number.NaN},o=[],h=new Map;for(const t of e){const i=n(t);o.includes(i)||o.push(i);const s=r(t.calcdate);h.has(s)||h.set(s,new Map),h.get(s).set(i,t)}try{const t=this.db.exec(`SELECT [category], MIN(categoryIndex) AS idx FROM ${this.fromExpr} GROUP BY [category]`),i=new Map(t.map((t=>[null==t.category?"":String(t.category),t.idx])));o.every((t=>Number.isFinite(i.get(t))))&&o.sort(((t,s)=>i.get(t)-i.get(s)))}catch(t){}const a=["scenario1","scenario2","scenario3","scenario4"];for(const s of t){const t=h.get(r(s.date));s.series=o.map((e=>{const n=null==t?void 0:t.get(e),r={};return a.forEach(((t,o)=>{const h=i[o];if(null==h)return;const a=null==n?void 0:n[h],l="number"==typeof a?a:Number.NaN,c=new mc(l,h,this.pixelPerUnit,Sc.NEU);Number.isFinite(l)&&(c.key={date:Uc.pointDate(s.date),scenario:h,category:e}),r[t]=c})),{key:e,points:r}}))}}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Xs(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!==at.AUTO)return t;const i=this.queryDates();if(0===i.length)return at.DAY;let s=i[0],e=i[0];for(const t of i)t<s&&(s=t),t>e&&(e=t);return(new ut).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=>Uc.coerceDateTime(t.date))).filter((t=>null!=t))}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=w.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=w.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:Dc.NONE,date:t.calcdate,scenario1:new mc(t[i[0]],i[0],this.pixelPerUnit,Sc.NEU),scenario2:new mc(t[i[1]],i[1],this.pixelPerUnit,Sc.NEU),scenario3:new mc(t[i[2]],i[2],this.pixelPerUnit,Sc.NEU),scenario4:new mc(t[i[3]],i[3],this.pixelPerUnit,Sc.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:Uc.pointDate(t.date),scenario:null!==(s=i.scenario)&&void 0!==s?s:void 0});return e}static pointDate(t){var i;return cs(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 mc(0,"default",i,Sc.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 mc(0,"default",i,Sc.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]),this.varianceOverlaps=0;const n=t.map((t=>new Xs(t)));if(this.scenarioSwitch&&n.filter((t=>t.isValid)).length>1)return this.populateSharedVarianceRow(t,n,i,e);for(const n in t){const r=new Xs(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 mc(this.calculateVariance(r,i[e],o),r.delta,a,h);this.scenarioSwitch&&(l.notation=r.base.slice(0,2)),null===l.value||Number.isNaN(l.value)||(l.key={date:Uc.pointDate(i[e].date),scenario:t[n]}),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Dc.RELATIVE:Dc.ABSOLUTE,date:i[e].date,scenario1:l,scenario2:new mc(null,null,null,null),scenario3:new mc(null,null,null,null),scenario4:new mc(null,null,null,null)})}}}return s}populateSharedVarianceRow(t,i,s,e){const n=[],r=i.map(((i,s)=>({variance:i,name:t[s]}))).filter((t=>t.variance.isValid)),o="dr"===r[0].variance.type,h=o?this.pixelPerPercentage:this.pixelPerUnit;return s.forEach(((t,i)=>{let s=null,a=0;for(const{variance:i,name:n}of r){const r=this.calculateVariance(i,t,this.mapScenarios(i,e));null===r||Number.isNaN(r)||(a++,null==s&&(s=new mc(r,i.delta,h,i.direction),s.notation=i.base.slice(0,2),s.key={date:Uc.pointDate(t.date),scenario:n}))}a>1&&this.varianceOverlaps++,n.push({id:i,category:t.category,type:o?Dc.RELATIVE:Dc.ABSOLUTE,date:t.date,scenario1:null!=s?s:new mc(null,r[0].variance.delta,h,r[0].variance.direction),scenario2:new mc(null,null,null,null),scenario3:new mc(null,null,null,null),scenario4:new mc(null,null,null,null)})})),n}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===Dc.RELATIVE?nt(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 ut;t.setLocale(this.locale);const i=this.i18n.get("date-format-short-year");return"string"==typeof i&&/y/.test(i)&&!i.includes("date-format")&&t.patchDateFormatShort({year:i}),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!==tt.RELATIVE&&this.determineEffectiveChartMode()!==ct.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=nc(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:ka.Bottom,offset:-s}:{hookLocation:ka.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===Dc.RELATIVE&&(n=!0);const h=this.axisLabelsMode===lt.SMART&&s.isSmartBoundary(t.date,this.dateInterval);if(i%this.axisLabelsStep!=0&&!h)return;let a=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===lt.SMART?(a=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==at.YEAR&&(a=s.getShortDateString(t.date,this.dateInterval))):(this.axisLabelsMode===lt.SHORT||this.axisLabelsMode===lt.TWO_ROW&&this.dateInterval!==at.YEAR)&&(a=s.getShortDateString(t.date,this.dateInterval)),new Ta(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+o,"",a,this.styles,r,ka.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===Dc.RELATIVE&&(n=!0)}new Mc({scenarioType:this.axisScenario,labelText:this.title,isRelative:n,titlePosition:this.axisTitlePosition,titleX:this.rightTitleX()},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width},this.drawScenarioSwitch(i)}drawScenarioSwitch(t){const i=this.switchRuns(),s=this.contextRow();if(i.length<2&&0===s.length)return;const e=t.group().id("ScenarioSwitch"),n=this.switchNamesHeight(),r=this.getAllocatedCanvasHeight(),o=n>0?r-this.styles.padding.bottom:r,h=Math.max(1,this.position.spacings.auxiliaryLineWidth);if(i.slice(1).forEach((t=>{const i=this.position.getColumnCenterPositionX(t.from)-this.position.spacings.categoryWidth/2;e.line(i,0,i,o).stroke({color:this.styles.fontStyles.color||"#000000",width:h}).addClass("scenario-switch")})),0===n)return;const a=this.axisLabelsMode===lt.TWO_ROW;s.forEach((t=>{const i=a?this.position.getColumnCenterPositionX(t.from)-this.position.getColumnWidth()/2:(this.position.getColumnCenterPositionX(t.from)+this.position.getColumnCenterPositionX(t.to))/2;new Ta(e,i,o-n,"SWITCH_"+t.scenario+"_"+t.from,t.text,this.styles,ka.Top,a?ka.Left:ka.Center).forceStringTypeDraw()}))}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;const r=this.followerSlots();t.forEach(((t,i)=>{const s=r.length>0?this.visibleSlot(t,r):"scenario1";null!=s&&"scenario1"!==s?(e.createPrimaryBar(t[s],i,!1).draw(this.dataFormatDigits,this.measureScale),n=!0):e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),"scenario2"!==s&&e.createSecondaryBar(t.scenario2,i).draw(),"scenario3"!==s&&e.createPrimaryMarker(t.scenario3,i).draw(),"scenario4"!==s&&e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let o=0;!1===n&&(o=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const h=s.bbox();this.scenariosArea={height:h.height+this.styles.padding.top+this.styles.padding.bottom+o,width:h.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new Ca,o=new Ec(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)=>(Ea[i.scenarioType]||99)-(Ea[t.scenarioType]||99)));const c=[];for(const t of l){const i=o.createLineSeries(t.points,t.scenarioName,Zs(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)=>(Ea[t.scenarioType]||99)-(Ea[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===lt.SMART?(l=s.getSmartDateString(i.date,this.dateInterval),0===o&&this.dateInterval!==at.YEAR&&(l=s.getShortDateString(i.date,this.dateInterval))):l=this.axisLabelsMode===lt.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):l=s.getShortDateString(i.date,this.dateInterval),new Ta(e,this.position.getColumnCenterPositionX(o),this.position.getAxisPositionY(n)+a,"",l,this.styles,h,ka.Center).forceStringTypeDraw(),o>0&&o<r&&this.isYearChange(t,o)&&this.drawYearSeparatorLine(e,o,n)})),new Mc({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===at.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:$i}).attr("stroke-dasharray",$i)}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Dc.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw(this.dataFormatDigits):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){var i;if(!this.stackConfig)return[];const s=this.stackConfig.by===Q.SCENARIOS,e=this.determineEffectiveChartMode()===ct.LINE,n=this.stackConfig.mode===tt.RELATIVE?dt:0,r=t=>Number.isFinite(t.value)?t.value:0,o=t=>{"asc"===this.stackConfig.order?t.sort(((t,i)=>r(t)-r(i))):"desc"===this.stackConfig.order&&t.sort(((t,i)=>r(i)-r(t)))};if(!s&&!e&&t.series){const s=null!==(i=this.visibleSlot(t,this.followerSlots()))&&void 0!==i?i:"scenario1",{fill:e}=this.seriesSlots(),r=[];return t.series.forEach(((t,i)=>{const n=Uc.hasAmount(t.points[s])?void 0:e.find((i=>Uc.hasAmount(t.points[i]))),o=t.points[null!=n?n:s];o&&r.push({value:o.value,scenario:o.scenario,dataPoint:o,colorIndex:i,label:t.key})})),r.some((t=>Number.isFinite(t.value)))?(o(r),[{prefix:"",segments:r,layout:sc(r.map((t=>t.value)),n),hasValue:!0}]):[]}const h=[];for(const i of s?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&h.push({value:s.value,scenario:s.scenario,dataPoint:s})}if(0===h.length)return[];const a=(t,i)=>({prefix:t,segments:i,layout:sc(i.map((t=>t.value)),n),hasValue:i.some((t=>Number.isFinite(t.value)))});if(s&&this.sortSegmentsByPropOrder(h),e)return[a("",h)];if(s){const t=new Map;for(const i of h){const s=Sa(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of xa)t.has(s)&&(i.push(a(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(a(s,e));return i}}return o(h),[a("",h)]}drawStackedScenarios(t,i){var s;if(!this.stackConfig)return;const{reference:e}=this.seriesSlots();if(e){const n=new Ec(this.position,i.group().id("StackReference"),this.scenarioStyles(),t.length,this.i18n),r=null!==(s=this.stackConfig.legend)&&void 0!==s?s:"left",o="left"!==r&&"both"!==r;t.forEach(((t,i)=>n.createSecondaryBar(t[e],i,o).draw()))}const n=i.group().id("StackedScenarios"),r=this.stackConfig.by===Q.SCENARIOS;t.forEach(((t,i)=>{const s=this.stackGroups(t);s.forEach(((e,o)=>{let h=null;e.segments.forEach(((t,a)=>{var l;const c=new Ac(this.position,this.styles,t.dataPoint,i,e.layout.segments[a],t.scenario,s.length>1?s.length-1-o:null!==(l=t.colorIndex)&&void 0!==l?l:a,this.stackConfig.mode,e.layout,r,n,"scenario"===this.stackConfig.notation,this.hasPercentMark());c.draw(this.dataFormatDigits,this.measureScale),h=c})),h&&e.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,{date:Uc.pointDate(t.date),scenario:s.length>1?e.prefix:void 0})}))}));const o=n.bbox();this.scenariosArea={height:o.height+this.styles.padding.top+this.styles.padding.bottom,width:o.width+this.position.spacings.columnWidth}}hasPercentMark(){var t;return(null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===tt.RELATIVE&&!0===this.stackConfig.percentMark}percentMarkSide(){var t;return"right"===(null===(t=this.stackConfig)||void 0===t?void 0:t.legend)?"right":"left"}seriesName(t){return this.i18n.get(t)||t}legendWidth(t){var i,s;if(!this.stackConfig||this.determineEffectiveChartMode()!==ct.BAR)return 0;const e=null!==(i=this.stackConfig.legend)&&void 0!==i?i:"left",n=[];if(e===t||"both"===e){const i=null===(s=this.dataModel.find((t=>null!=t.series)))||void 0===s?void 0:s.series;i?n.push(...i.map((t=>this.seriesName(t.key)))):"right"===t&&this.stackConfig.by===Q.SCENARIOS&&n.push(...this.lastScenarios.map((t=>this.i18n.get(t)||t)))}this.hasPercentMark()&&this.percentMarkSide()===t&&n.push("100%");let r=0;for(const t of n)r=Math.max(r,wa(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width);return r}drawStackedHeaders(t,i){var s,e,n;if(!this.stackConfig||0===t.length)return;const r=this.stackConfig.by===Q.SCENARIOS,o=t.some((t=>null!=t.series));if(!r&&!o)return;const h=i.group().id("StackedHeaders"),a=this.position.getColumnPositionY(),l=this.position.getColumnWidth()/2,c=this.position.spacings.labelToColumn,u=t.map(((t,i)=>this.stackGroups(t).length>0?i:-1)).filter((t=>t>=0)),d=o&&null!==(s=u[0])&&void 0!==s?s:0,f=null!==(e=u[u.length-1])&&void 0!==e?e:t.length-1,v=i=>{const s="left"===i?d:f,e=this.stackGroups(t[s]);if(0===e.length)return;const n=this.position.getColumnCenterPositionX(s),r="left"===i?n-l-c:n+l+c,o=(t,s)=>{new Ta(h,r,t,"STACK_HEADER",s,this.styles,ka.Center,"left"===i?ka.Right:ka.Left).forceStringTypeDraw()};if(e.length>1)return void e.forEach(((t,i)=>{const{positive:s,negative:n,total:r}=t.layout;o(a-(i===e.length-1?(s-n)/2:r<0?0-n:s)*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[u]=e;u.segments.forEach(((t,i)=>{if(null!=t.label&&!Number.isFinite(t.value))return;const{start:s,end:e}=u.layout.segments[i];o(a-(s+e)/2*t.dataPoint.pixelPerUnit,null!=t.label?this.seriesName(t.label):this.i18n.get(t.scenario)||t.scenario)}))},p=null!==(n=this.stackConfig.legend)&&void 0!==n?n:"left";"left"!==p&&"both"!==p||v("left"),"right"!==p&&"both"!==p||v("right"),this.hasPercentMark()&&u.length>0&&this.drawPercentMark(h,"left"===this.percentMarkSide()?d:f)}drawPercentMark(t,i){const s=this.percentMarkSide(),e="left"===s?-1:1,n=this.position.getColumnPositionY()-dt*this.pixelPerUnit,r=this.position.getColumnCenterPositionX(i)+e*(this.position.getColumnWidth()/2),o=.45*this.styles.fontStyles.size,h=r+1*e,a=h+e*o;t.polygon([[h,n],[a,n-o/2],[a,n+o/2]]).fill(this.styles.fontStyles.color||"#000000").addClass("percent-mark"),new Ta(t,a,n-o/2,"STACK_PERCENT_MARK","100%",this.styles,ka.Bottom,"left"===s?ka.Right:ka.Left).forceStringTypeDraw()}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 e?r:["scenario1"])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===tt.RELATIVE?dt:0,u=t.map((t=>sc(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?Zs(this.ruleSet.getScenarioColorIndex(o[t])):null,h=new Lc(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 Ec(this.position,s,this.scenarioStyles(),t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=Fc(t),s=i.length>0?i.reduce(((t,i)=>t+i),0)/i.length:NaN,e=Object.assign(Object.assign({},t[0]),{scenario1:new mc(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new mc(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 mc(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=Fc(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 mc(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new mc(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 mc(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=w.max(...s),n=w.min(...s),r=new ut;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 Fc(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 Gc{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=at.AUTO,this.axisLabelsMode=lt.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=ct.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.axisLabelsStep=1,this.scalingIndicator=0,this.totals=null,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.locale="de"}}class jc{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=it.adaptArray(t.data,this.dataRowAdapter),s=it.adaptArray(t.scenarios,this.stringAdapter),e=new Gc(i,s);R.isArray(t.variances)&&(e.variances=it.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.isNumber(t.axisLabelsStep)&&t.axisLabelsStep>=1&&(e.axisLabelsStep=t.axisLabelsStep),R.isNumber(t.scalingIndicator)&&t.scalingIndicator>0&&(e.scalingIndicator=t.scalingIndicator);const n=t.totals;if(null!=n&&R.isNumber(n.pixelPerUnit)&&n.pixelPerUnit>0){const t=["all","year","quarter","month","week"].includes(n.by)?n.by:"all",i=["sum","average","last"].includes(n.aggregation)?n.aggregation:"sum";e.totals={by:t,aggregation:i,pixelPerUnit:n.pixelPerUnit,label:"string"==typeof n.label?n.label:"",width:R.isNumber(n.width)&&n.width>0?n.width:1,dataset:"string"==typeof n.dataset?n.dataset:""}}return R.isBoolean(t.scenarioSwitch)&&(e.scenarioSwitch=t.scenarioSwitch),R.isString(t.axisTitlePosition)&&(e.axisTitlePosition=t.axisTitlePosition),R.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Gc([],[])}}const Ic=class{disconnectedCallback(){var t;this.overlapErrId&&(null===(t=this.errors)||void 0===t||t.remove(this.overlapErrId),this.overlapErrId=void 0)}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=at.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=lt.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=ct.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.axisLabelsStep=1,this.scalingIndicator=0,this.totals=null,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.parentDimensions={width:0,height:0},l(this)}getDb(){return this.stores||(this.stores=u(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,s,e,n,r,o,h,a,l,c;if(this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),wi(this.errors,this.queryError),this.variances.every((t=>""===t))){const t=null!==(e=null===(s=this.chart)||void 0===s?void 0:s.getIgnoredSwitchScenarios())&&void 0!==e?e:[];t.length>0?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_stack_switch_ignored",type:"warning",message:`stack by dimensions with scenarioSwitch: ${t.join(", ")} is not drawn. A scenario continues the first one only where the first one has no value, and only in bar mode.`}):null===(r=this.errors)||void 0===r||r.remove("WARN_stack_switch_ignored")}const u=`WARN_variances_overlap_${this.variances.join("_")}`,d=null!==(h=null===(o=this.chart)||void 0===o?void 0:o.getVarianceOverlaps())&&void 0!==h?h:0;this.overlapErrId&&this.overlapErrId!==u&&(null===(a=this.errors)||void 0===a||a.remove(this.overlapErrId)),this.overlapErrId=d>0?u:void 0,d>0?null===(l=this.errors)||void 0===l||l.addOrReplace({id:u,type:"warning",message:`scenarioSwitch: the variances ${this.variances.join(", ")} share a row, but ${d} period(s) have more than one value. The first variance wins there.`}):null===(c=this.errors)||void 0===c||c.remove(u)}async componentWillLoad(){var t,i;const s=this.prepareConfig(),e=this.prepareStyle(),n=this.containerWidth||0;this.chart=new Uc(new se(this.ruleSetConfig),this.getDb(),this.tableName,s,e,n),this.chart.setI18n(this.i18n);const r=s.pixelPerUnit<=0,o=s.pixelPerPercentage<=0;this.autoFitScaling(s,e),this.chart.setAvailableHeight(r?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),o||this.chart.fitRelativeVariances((null===(i=this.parentDimensions)||void 0===i?void 0:i.height)||0),this.pattern=new pc(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t,i;if(null==this.chart)return;const s=this.prepareConfig(),e=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(e),this.chart.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new se(this.ruleSetConfig)),this.chart.setConfig(s);const n=s.pixelPerUnit<=0,r=s.pixelPerPercentage<=0;this.autoFitScaling(s,e),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),r||this.chart.fitRelativeVariances((null===(i=this.parentDimensions)||void 0===i?void 0:i.height)||0),this.pattern=new pc(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 Uc(new se(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(Ql,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=ic({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(Ql,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Ql,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=M(e,this.tableName,this.filter);return this.measureScaleError=void 0,new jc(new yc,new Tl,new hc,e,n,(t=>{this.measureScaleError=yi(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,axisLabelsStep:this.axisLabelsStep,scalingIndicator:this.scalingIndicator,totals:this.totals,scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.axisTitlePosition,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 xc(new uc,new ne,new ue(new le),new ll(new le),new oe).adapt(this.styles);return s.locale=(null===(i=null===(t=u(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};Ic.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 Bc=class{constructor(i){t(this,i),this.name="_default",l(this),this.errors=c(this),hi(this,(t=>{this.stores||(this.stores=u(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("ERR_body");const s=k(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)}};Bc.style="bn-component-style{display:none}";const Yc={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"]},Hc=Object.keys(Yc),Vc=["landscape","portrait"];function Xc(t,i){const s=null!=t&&Hc.includes(t),[e,n,r]=Yc[s?t:"xga"],o=e>=n?"landscape":"portrait",h=s&&Vc.includes(null!=i?i:"")?i:o,[a,l]=h===o?[e,n]:[n,e];return{width:`${a}${r}`,height:`${l}${r}`,orientation:h}}function Jc(t,i,s){const e=Xc(t,i),n=Vc.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 qc(t,i,s){const{width:e,height:n}=Jc(t,i,s);return`@page { size: ${e} ${n}; }`}const Kc=new Map,Qc={"thin-space":" ",space:" ",none:""};function Zc(t){var i;let s="";for(const t of Kc.values())s=t.separator()||s;const e=s?null!==(i=Qc[s])&&void 0!==i?i:s:null;if(e!==Oa.groupSeparator){Oa.groupSeparator=e;for(const[i,s]of Kc)i!==t&&s.redraw()}}const tu=["format","orientation","page-format","page-orientation","render-orientation","page-number"],iu=(t,i,s)=>{const e=t[i];return"string"==typeof e?e:i in t?null:t.getAttribute(s)},su=class{constructor(i){t(this,i),this.bnNotationChange=o(this,"bnNotationChange",7),this.groupSeparator="",this.wasConnected=!1,this.assignedPageNumbers=new WeakMap,this.notationSubscriptions=[],l(this),this.errors=c(this)}watchGroupSeparator(){Zc()}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=O(this.element),this.locale&&(this.stores.context.state.locale=this.locale),Kc.set(this,{separator:()=>{var t;return null!==(t=this.groupSeparator)&&void 0!==t?t:""},redraw:()=>{const t=this.stores.context.state,i=t.locale;t.locale="",t.locale=i}}),Zc(this.wasConnected?void 0:this),this.wasConnected=!0;const t=()=>this.bnNotationChange.emit();this.notationSubscriptions=[this.stores.scalingGroups.on("set",t),this.stores.componentStyles.on("set",t)],this.syncPages(),this.pageObserver=new MutationObserver((()=>this.syncPages())),this.pageObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:tu})}disconnectedCallback(){var t,i;Kc.delete(this),Zc(),this.notationSubscriptions.forEach((t=>t())),this.notationSubscriptions=[],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=iu(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?qc(iu(t,"pageFormat","page-format"),iu(t,"pageOrientation","page-orientation"),i):qc(iu(t,"format","format"),iu(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}):is(t,s)}catch(i){let e;try{e=is(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:bi,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=fi(n.map((t=>({tag:t.localName,explicitId:vi(t)}))));return h.forEach(((t,i)=>{t.id=a[i]})),{version:bi,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:pi(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:h}}async getNotation(t){const i=Array.from(this.element.querySelectorAll("bn-component-style, bn-scaling-group"));return await Promise.all(i.map((t=>{var i,s;return null!==(s=null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t))&&void 0!==s?s:Promise.resolve()}))),Mi(ft(this.stores.componentStyles.state,t),this.stores.scalingGroups.state)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"835bf8fe0cf78440c000ce996495c5c5c0cbbd07"},i("slot",{key:"395cbc8fdbb4f6e765d36a93a7547272e5ec7def"}))}get element(){return e(this)}static get watchers(){return{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}}};su.style=":host{display:block}";const eu=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],nu=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function ru(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function ou(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var hu=Uint8Array,au=Uint16Array,lu=Int32Array,cu=new hu([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]),uu=new hu([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]),du=new hu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fu=function(t,i){for(var s=new au(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new lu(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}},vu=fu(cu,2),pu=vu.b,gu=vu.r;pu[28]=258,gu[258]=28;for(var mu=fu(uu,0).b,bu=new au(32768),yu=0;yu<32768;++yu){var wu=(43690&yu)>>1|(21845&yu)<<1;bu[yu]=((65280&(wu=(61680&(wu=(52428&wu)>>2|(13107&wu)<<2))>>4|(3855&wu)<<4))>>8|(255&wu)<<8)>>1}var xu=function(t,i,s){for(var e=t.length,n=0,r=new au(i);n<e;++n)t[n]&&++r[t[n]-1];var o,h=new au(i);for(n=1;n<i;++n)h[n]=h[n-1]+r[n-1]<<1;if(s){o=new au(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[bu[u]>>a]=l}else for(o=new au(e),n=0;n<e;++n)t[n]&&(o[n]=bu[h[t[n]-1]++]>>15-t[n]);return o},Su=new hu(288);for(yu=0;yu<144;++yu)Su[yu]=8;for(yu=144;yu<256;++yu)Su[yu]=9;for(yu=256;yu<280;++yu)Su[yu]=7;for(yu=280;yu<288;++yu)Su[yu]=8;var $u=new hu(32);for(yu=0;yu<32;++yu)$u[yu]=5;var Mu=xu(Su,9,1),_u=xu($u,5,1),ku=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},Ou=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},Nu=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},Au=["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||Au[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,Ru),!s)throw e;return e},Lu=new hu(0);function Tu(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 hu(0);var r=!s,o=r||2!=i.i;r&&(s=new hu(3*n));var h,a,l=function(t){var i=s.length;if(t>i){var e=new hu(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=Ou(t,u,1);var b=Ou(t,u+1,3);if(u+=3,!b){var y=t[(R=4+((u+7)/8|0))-4]|t[R-3]<<8,w=R+y;if(w>n){Ru(0);break}o&&l(d+y),s.set(t.subarray(R,w),d),i.b=d+=y,i.p=u=8*w,i.f=c;continue}if(1==b)f=Mu,v=_u,p=9,g=5;else if(2==b){var x=Ou(t,u,31)+257,S=Ou(t,u+10,15)+4,$=x+Ou(t,u+5,31)+1;u+=14;for(var M=new hu($),_=new hu(19),k=0;k<S;++k)_[du[k]]=Ou(t,u+3*k,7);u+=3*S;var O=ku(_),N=(1<<O)-1,A=xu(_,O,1);for(k=0;k<$;){var R,L=A[Ou(t,u,N)];if(u+=15&L,(R=L>>4)<16)M[k++]=R;else{var T=0,E=0;for(16==R?(E=3+Ou(t,u,3),u+=2,T=M[k-1]):17==R?(E=3+Ou(t,u,7),u+=3):18==R&&(E=11+Ou(t,u,127),u+=7);E--;)M[k++]=T}}var P=M.subarray(0,x),C=M.subarray(x);p=ku(P),g=ku(C),f=xu(P,p,1),v=xu(C,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=(T=f[Nu(t,u)&W])>>4;if((u+=15&T)>m){Ru(0);break}if(T||Ru(2),U<256)s[d++]=U;else{if(256==U){z=u,f=null;break}var F=U-254;U>264&&(F=Ou(t,u,(1<<(I=cu[k=U-257]))-1)+pu[k],u+=I);var G=v[Nu(t,u)&D],j=G>>4;if(G||Ru(3),u+=15&G,C=mu[j],j>3){var I=uu[j];C+=Nu(t,u)&(1<<I)-1,u+=I}if(u>m){Ru(0);break}o&&l(d+131072);var B=d+F;if(d<C){var Y=0-C,H=Math.min(C,B);for(Y+d<0&&Ru(3);d<H;++d)s[d]=e[Y+d]}for(;d<B;++d)s[d]=s[d-C]}}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 hu(h.subarray(0,a))):s.subarray(0,d)}(t.subarray(n,-8),{i:2},new hu(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var Eu="undefined"!=typeof TextDecoder&&new TextDecoder;try{Eu.decode(Lu,{stream:!0})}catch(t){}function Pu(t){return vt(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=Tu(r);return{hash:s,json:(new TextDecoder).decode(o)}}const Wu=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=l(this),this.errors=c(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=u(i),r=(i.getAttribute("datasources")||"").split(","),h(),a.observe(i,{attributes:!0,attributeFilter:["datasources"]}),f(l,t)};const c=t.disconnectedCallback;t.disconnectedCallback=()=>{a.disconnect(),n.forEach((t=>t())),n=[],v(e(t)),f(c,t)}})(this,(()=>{this.executeQuery()})),hi(this,(t=>this.sync(t)))}sync(t){if(this.stores=u(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: ${yi(t)}`}),void(this.lastBodyHash=null)}else i=Pu(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=u(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: ${yi(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(p(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 nu)i[t]=new Set;const s={};for(const t of eu)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 nu){const s=h[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of eu){const i=h[t];if(ru(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=eu.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=ou(i.rowGroup),c=ou(i.category),u=ou(i.subCategory),d=ou(i.columnGroup),f=ou(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=u(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: ${yi(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}]}}};Wu.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=l(this),this.errors=c(this),hi(this,(t=>this.sync(t)))}sync(t){var i;if(this.stores=u(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=Pu(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: ${yi(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),v(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=u(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: ${yi(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 zu=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,l(this),this.errors=c(this),this.componentStyle=N(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)}};zu.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 Uu=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"']]),Fu="custom-template",Gu=/"[\w\d\s.]+"|'[\w\d\s.]+'/g,ju=/"[^"]*"|'[^']*'/g;function Iu(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 Bu(t,i){var s;return t===Fu?Iu(i).length>0?i:'"a"':null!==(s=Uu.get(t))&&void 0!==s?s:'"a"'}function Yu(t){var i;const s=(null===(i=Iu(t)[0])||void 0===i?void 0:i.length)||1;return Array(s).fill("minmax(0, 1fr)").join(" ")}function Hu(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 Vu(t){var i;const s=Iu(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(ju))&&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 Xu=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.cardOverlayArea="",this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,l(this),this.errors=c(this),this.componentStyle=N(this),this.resolveInherited=ri(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=u(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 Yu(this.getTemplatePattern(t))}getRowCount(t){return Iu(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(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))),this.overlayArea()?i("div",{style:{display:"flex",overflow:"hidden","grid-area":this.overlayArea(),"z-index":"1"}},i("slot",{name:"card-slot-"+s.length})):null)}overlayArea(){var t,i;const s=(null!==(t=this.cardOverlayArea)&&void 0!==t?t:"").trim();if(!/^\d+(\s*\/\s*\d+){3}$/.test(s))return;const[e,n,r,o]=s.split("/").map((t=>Number(t.trim()))),h=this.getRowCount(this.cardLayout),a=(null===(i=Iu(this.getTemplatePattern(this.cardLayout))[0])||void 0===i?void 0:i.length)||1;return e>=1&&n>=1&&r<=h+1&&o<=a+1&&e<r&&n<o?s:void 0}extractSlotNames(t){return Hu(t)}getTemplatePattern(t){return Bu(t,this.cardCustomTemplate)}componentWillRender(){var t;const i=this.cardLayout===Fu?Vu(this.cardCustomTemplate):void 0;i?this.errors.addOrReplace({id:"WARN_cardCustomTemplate",type:"warning",message:`cardCustomTemplate: ${i}`}):this.errors.remove("WARN_cardCustomTemplate"),""===(null!==(t=this.cardOverlayArea)&&void 0!==t?t:"").trim()||this.overlayArea()?this.errors.remove("WARN_cardOverlayArea"):this.errors.addOrReplace({id:"WARN_cardOverlayArea",type:"warning",message:`cardOverlayArea: '${this.cardOverlayArea}' is not 'row-start / column-start / row-end / column-end' in line numbers of the layout.`})}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:"ef0b6da39a573f162c096c21803e4d647b2817c2",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"9116df8c88198ebc922dc91d5f45a032a81d37d1",class:"cardtitle"},i("bn-title",{key:"6d9645d5229c3bf32ef944c1f296a55dbe4b3bee","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.titleProp("ruleset"),"title-font-size":this.componentStyle((t=>{var i;return null===(i=null==t?void 0:t["bn-layout-card"])||void 0===i?void 0:i.titleFontSize})),"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:"65803497adad305f02874acf441867e9ba200945"},i("div",{key:"61a57b87b0ffb76c238b2e2facb7d5b855d5dc10",style:s,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(e))),i("bn-footer",{key:"8589da921d0f8dac8e9a2af23315ded3a3ee3d51",text:this.footerText,"page-number":"0","display-page-number":"false"}))}get element(){return e(this)}};Xu.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 Ju=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,l(this),this.errors=c(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 Iu(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(h,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){return Hu(t)}getTemplateAreas(t){return Bu(t,this.pageCustomTemplate)}getGridTemplateColumns(t){return(i=t)===Fu||Uu.has(i)?Yu(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===Fu?Vu(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=Jc(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)}};Ju.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 qu=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(this)}connectedCallback(){this.stores=u(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:Vt(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)}};qu.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 Ku=class{constructor(i){t(this,i),l(this),this.errors=c(this),this.componentStyle=N(this)}validateFormat(t){const i="WARN_format";L(t)||Hc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${Hc.join(", ")}`})}validateOrientation(t){const i="WARN_orientation";L(t)||Vc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${Vc.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(Hc.includes(this.format)){const{width:i,height:s}=Xc(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}]}}};Ku.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 Qu=class{constructor(i){t(this,i),l(this),this.errors=c(this)}connectedCallback(){this.stores=u(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=oi(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=oi(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 (${ni(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}]}}};Qu.style="bn-scaling-group{display:none}";const Zu="none",td="setname";function id(t){return t===td?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function sd(t){if("string"==typeof t?""===t.trim():"number"!=typeof t)return;const i=Number(t);return Number.isFinite(i)?i:void 0}function ed(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=nd(t);return i?i.toISO():String(t)}function nd(t){if(null!=t){if("string"==typeof t){const i=w.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=w.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const rd=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.runningSum=!1,this.varianceWaterfall=!1,this.type="list",this.limit=0,this.thereof="[]",this.thereofPosition="below",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 ≈ ${ni(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 ≈ ${ni(i)} percentage points.`}))}},E(this),l(this),this.errors=c(this),_s(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this),Zt(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 L(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!==sd(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&L(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=ti(this).t,this.resolveInherited=ri(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";p(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(qt(t))return void this.errors.remove(i);const s=V(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(qt(t))return void this.errors.remove(i);const s=X(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(L(t))return void this.errors.remove(i);const s=pt(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";gt(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"===ei(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"===ei(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";mt(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";bt(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";T(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=yt(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)}validateThereofPosition(t){const i="WARN_thereofPosition";L(t)||wt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"thereofPosition: invalid value '"+t+"' is not supported."})}validatePartOf(t){const i="WARN_partof",s=xt(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(qt(t))return void this.errors.remove(i);const s=St(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";qt(t)||G(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";$t(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";q(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";T(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";T(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";Mt(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=_t(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();L(t)||s===Zu||s===td||ot(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";L(t)||T(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=kt(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.validateThereofPosition(this.thereofPosition),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=$s(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Xt(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(){Bs(this.element,"bn-table-renderer");const{mode:t}=ii(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}=Xt(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=Xt(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 _(this.errors,null);const{mode:r}=ii(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)`),_(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 Ot[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareThereofPosition(){var t;return(null===(t=this.thereofPosition)||void 0===t?void 0:t.toLowerCase())===Nt.ABOVE?Nt.ABOVE:Nt.BELOW}prepareTableType(){var t;return At[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=>Rt(t))),direction:I[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return Lt.META}prepareI18n(){const t=g,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(),...ie(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 L(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((L(u.value)||f)&&L(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||L(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 L(this.categoryWidth)?Tt.INF:Tt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return L(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 L(this.measureType)?Et.VOLUME:Et[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=L(this.interval)?Zu:this.interval.trim().toLowerCase();return r!==Zu&&r!==td&&!ot(r)||r===Zu?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),this.errors.remove(n),Zu):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),Zu):(this.errors.remove(i),r===td?(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),td):(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."}),Zu):(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?Pt(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=Wt[i];return s?Ct[s]:Ct[Wt.W10]}prepareBarColumns(){return L(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=ei(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=ei(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=ui(i),n={},r=t.querySelector("thead");if(r){const t=e.toLocal(r.getBoundingClientRect());n.y=es(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];if(u){const t=u.classList.contains("block-start")&&"function"==typeof getComputedStyle&&parseFloat(getComputedStyle(u).borderLeftWidth)||0;n.x=es(e.toLocal(u.getBoundingClientRect()).x+t)}return 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=di(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:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:[],metadata:{},diagnostics:ai(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=ei(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=ei(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}=ii(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:"2af1b7f31952cd0ba32e0a069ce143d3402b4a77",style:t},i("div",{key:"b78ad13abb48a43c1da0aec4727372a482c39701"},i("bn-table-renderer",{key:"ab0132a3b57953379f6d8f5f19a18f95a14cc326",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereof:this.prepareThereOf(),thereofPosition:this.prepareThereofPosition(),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}],thereofPosition:[{validateThereofPosition: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}]}}};rd.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 od=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class hd{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){return this.format(this.value,t,i)}roundsToZero(t,i){return"number"==typeof this.value&&!!this.type&&this.draw(t,i)===this.format(0,t,i)}format(t,i,s){let e=t;if("undefined"===e||void 0===e||null==e)return"";if(Number.isNaN(Number(e)))return e;if(""===this.type||void 0===this.type||null==this.type)return e;let n=i.percent,r=i.percent;return"percentpoint"===this.type?Oa.number(Number(e),"percent",n,r,1,s).replace(od,""):("decimal"===this.type&&(e=+e/this.measureScale,n=i.decimal,r=i.decimal),Oa.number(Number(e),this.type,n,r,1,s))}drawPrefix(){return null==this.prefix?"":this.prefix}}class ad{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Dt.HEADER:return"groupheader";case Dt.SEPERATORLINE:return"";case Dt.DRILLELEMENT:return"ofit";case Dt.PARTELEMENT:return"partof";case Dt.STANDARD:return"";case Dt.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;if("category"===i&&null!=h&&(f=`category-${h.toString()}`),this.type===Dt.HEADER?f="headerlabel":this.type===Dt.SEPERATORLINE&&(f=null!=r?r:i),this.type===Dt.PARTELEMENT){const s=new Xs(i);s.isValid&&Number.isFinite(t)?(e="d"===s.type?"percentpoint":"percent",f=(null!=r?r:"").replace(/^(pos|neg)_\w+/,"$1_neu")):(("percent"===e||s.isValid)&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",f=""))}("-"===t||t===et&&"percent"===e)&&(f="");let v="prefix-first";o&&(v="prefix-second"),s&&(f=`${f} ${s}`);const p=new hd(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 ld=.85,cd=.3,ud=.25;function dd(t){const i=.6*t;return{barY:(t-i)/2,barHeight:i}}const fd={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};let vd;function pd(t,i,s,e,n=!1){const r=()=>function(t,i){var s;let e=0;for(const i of t)e+=null!==(s=fd[i])&&void 0!==s?s:/[0-9+]/.test(i)?.59:.72;return e*i*1.1}(t,i)*(n?1.08:1),o=function(){var t,i,s;if(void 0===vd)try{vd="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){vd=null}return vd}();if(o){o.font="1px __bn_font_sentinel__";const h=o.font;if(o.font=`${e?"italic ":""}${n?"bold ":""}${i}px ${s}`,o.font===h)return r();const a=o.measureText(t).width;if(Number.isFinite(a)&&(a>0||""===t))return a+.15*i}return r()}function gd(t,i){return Math.max(0,(t-.5)*i)}function md(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 bd(t,i,s,e){const{sides:n,neg:r,pos:o}=md(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 yd(t,i,s,e){const n=gd(t,i),{sides:r,neg:o,pos:h}=md(s,e/2,cd*i);return o+h+r*function(t,i,s){return Math.min(1*i,t/(2*s))}(n,i,r)<=n+1e-6}function wd(t,i){const s=.15*t;return{maxBarWidth:t,breakGap:i,overdriveZoneWidth:s,cutWidth:Math.max(0,t-i-s)}}function xd(t,i,s,e){var n,r;const o=gd(t,i),h=cd*i,{extent:a,axisX:l}=bd(o,s,ud*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:wd(f,c),pos:wd(g,c),axisX:u?l-a+f:0,labelGap:h}}function Sd(t,i,s,e,n){var r,o;const h=gd(t,i),a=cd*i,{extent:l,axisX:c}=bd(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}}function $d(t,i,s){const e=gd(t,i),n=cd*i,r=Math.min(2.85*i,e/4);let o=r,h=r;const a=s?s.max-s.min:0;if(s&&a>0){const t=(t,i)=>Math.max(0,...s.labels.filter((i=>i.pointsLeft===t)).map((e=>e.width+n-(t?e.end-s.min:s.max-e.end)*i)));o=t(!0,0),h=t(!1,0);const i=e/2;for(let s=0;s<8;s++){const s=Math.max(0,e-o-h)/a,n=Math.min(o,t(!0,s)),r=Math.min(h,t(!1,s)),l=n+r<=i||n===o&&r===h;if(o=n,h=r,l)break}if(o+h>i)if(Math.min(o,h)>r){const t=i/(o+h);o*=t,h*=t}else o<=h?h=i-o:o=i-h}return{totalWidth:e,labelAreaLeft:o,labelAreaRight:h,barAreaWidth:e-o-h,labelGap:n}}const Md={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},_d="#666666";function kd(t,i){return`pattern-${t}-${i.replace("#","")}`}function Od(t,i){return kd(`head-${t}`,i)}const Nd=({styles:t})=>{const s=t.scaleFactor,e=3*s,n=[{id:kd("pos",t.positive.stroke),line:t.positive.stroke,background:"#ffffff",lineWidth:1},{id:kd("neg",t.negative.stroke),line:t.negative.stroke,background:"#ffffff",lineWidth:1},{id:kd("neu",t.neutral.stroke),line:t.neutral.stroke,background:"#ffffff",lineWidth:1},...["ac","pp","fc","pl"].flatMap((i=>[{id:kd(i,t.scenarios[i].stroke),line:t.scenarios[i].stroke,background:"#ffffff",lineWidth:1},{id:Od(i,t.scenarios[i].stroke),line:"#ffffff",background:t.scenarios[i].stroke,lineWidth:.6}]))],r=[[0,e,e,0],[-s,s,s,-s],[e-s,e+s,e+s,e-s]];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:t.background}),r.map((([e,n,r,o])=>i("line",{x1:e,y1:n,x2:r,y2:o,stroke:t.line,"stroke-width":t.lineWidth*s})))))))};function Ad(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?Oa.number(t,"percent",i,i,1,e):Oa.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=>Oa.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(Oa.number(a/c,"decimal",d,0,1,e),Oa.number(0,"decimal",d,0,1,e))+u}function Rd(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 Td(t,i){if(Rd(t))return null;const s=new Xs(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 Ed=({x:t,height:s,look:e,styles:n})=>{const r=n.scaleFactor,o=ud*n.emPx,{reference:h,referenceSlot:a}=e;let l;if("outlined"===h.fillpattern){const e=o/3,n=(o-e)/2;l=[t-n,t+n].map((t=>i("line",{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":e})))}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 Pd(t){return void 0!==t.pos||void 0===t.neg}function Cd(t,i){return{neg:t.min<0?i:void 0,pos:t.max>0?i:void 0}}function Wd(t,i,s,e){return Rd(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 Dd(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${kd(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function zd(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Ud=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,bold:v,styles:p=Md}=t,g=p.scaleFactor,m=p.fontSize,b=h||Ad(s,!1,a,l,0,!0,c),y=null!=d?d:Cd(n,pd(b,m,p.fontFamily,!1,v)),w=s>0||0===s&&Pd(y),{neg:x=Math.max(0,-n.min),pos:S=Math.max(0,n.max)}=null!=f?f:{},$=xd(u,p.emPx,y,{neg:x,pos:S}),{totalWidth:M,axisX:_,labelGap:k}=$,{breakGap:O,overdriveZoneWidth:N,cutWidth:A}=w?$.pos:$.neg,R=Math.abs(s)*p.unitScaling*m,L=R-A>1e-6,T=Math.max(0,(w?S:x)*p.unitScaling*m-A),E=Math.max(0,R-A),P=T>0?E/T*N:0,{barY:C,barHeight:W}=dd(r),D=Td(e,p),z=Wd(e,s,o,p),U=null==D?void 0:D.minuend.fillpattern,F="hatched"===U||"outlined"===U?Object.assign(Object.assign({},z),{fillpattern:U}):z,G=Dd(F,Rd(e)?Ld(e):o?w?"pos":"neg":w?"neg":"pos"),{stroke:j,strokeWidth:I}=D&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:zd(F),B=D?ud*p.emPx/2:0,Y=w?_+B:_-B,H=L?A:R,V=L?A+O+P:R,X=w?Y+V+k:Y-V-k,J=w?"start":"end";return i("svg",{width:M,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(Nd,{styles:p}),!D&&i("line",{x1:_,y1:0,x2:_,y2:r,stroke:_d,"stroke-width":1*g}),H>0&&i("rect",{x:w?Y:Y-H,y:C,width:H,height:W,fill:G,stroke:j,"stroke-width":I*g}),L&&P>0&&i("rect",{x:w?Y+A+O:Y-A-O-P,y:C,width:P,height:W,fill:G,stroke:j,"stroke-width":I*g}),L&&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})]}(w?Y+A:Y-A-O,O,C,W,g),D&&i(Ed,{x:_,height:r,look:D,styles:p}),i("text",{x:X,y:r/2,dy:"0.35em","text-anchor":J,fill:p.fontColor,"font-size":m,"font-family":p.fontFamily},b))},Fd=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,bold:m,styles:b=Md}=t,y=b.scaleFactor,w=b.fontSize,x=8*y,S=100*b.percentageScaling*w,$=l||Ad(n,!0,c,u,d,f),M=pd($,w,b.fontFamily,!0,m),_=null!=p?p:Cd(o,M),{neg:k=Math.max(0,-o.min),pos:O=Math.max(0,o.max)}=null!=g?g:{},{totalWidth:N,negPinLength:A,posPinLength:R,axisX:L,labelGap:T}=Sd(v,b.emPx,_,x,{neg:k*S,pos:O*S}),E=h/2,P=Math.abs(n)*S,C=n>0||0===n&&Pd(_),W=C?R:A,D=P-W>1e-6,z=C?1:-1,U=L+z*Math.min(P,W),F=Wd(r,n,a,b),G=Td(r,b),j=null!==(s=null==G?void 0:G.minuend)&&void 0!==s?s:b.scenarios.ac,I=L+z*(W+x/2),B=1.2*x,Y=I-z*B,H=.2*w,V=M+2*H,X=Math.abs(Y-L)-ud*b.emPx/2,J=D&&X>=V+2*H,q=Y-z*(H+V/2)-V/2,K=J?q+V/2:(D?I:U+z*(x/2))+z*T;return i("svg",{width:N,height:h,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i(Nd,{styles:b}),D?i("polygon",{points:`${I},${E} ${Y},${E-B/2} ${Y},${E+B/2}`,fill:F.fill}):i("rect",{x:U-x/2,y:E-x/2,width:x,height:x,fill:"outlined"===j.fillpattern?"#ffffff":"hatched"===j.fillpattern?`url(#${Od(null!==(e=null==G?void 0:G.minuendSlot)&&void 0!==e?e:"ac",j.stroke)})`:j.fill,stroke:j.stroke,"stroke-width":1*y}),i("line",{x1:L,y1:E,x2:D?Y:U,y2:E,stroke:F.fill,"stroke-width":3*y}),J&&i("rect",{class:"pin-label-band",x:q,y:E-3*y/2,width:V,height:3*y,fill:"#ffffff","fill-opacity":"0.5"}),G?i(Ed,{x:L,height:h,look:G,styles:b}):i("line",{x1:L,y1:0,x2:L,y2:h,stroke:_d,"stroke-width":1*y}),i("text",{x:K,y:h/2,dy:"0.35em","text-anchor":J?"middle":C?"start":"end",fill:b.fontColor,"font-size":w,"font-style":"italic","font-family":b.fontFamily},$))},Gd=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=Md}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?Fd:Ud,Object.assign({},t))};function jd(t,i,s,e,n,r=!1){const o=Ad(t,"partof"===i,s,e,0,!0,n);return r?o:o.replace(/^\+/,"")}const Id=t=>{var s;const{value:e,scenario:n,height:r,isPositiveGood:o,measureScale:h,locale:a,decimalDigits:l,columnWidthEm:c=10,styles:u=Md,waterfall:d,geometry:f,bold:v,connectorReach:p={top:0,bottom:0}}=t,g=u.scaleFactor,m=u.fontSize,b=d.max-d.min;if(null==e||isNaN(e)||b<=0)return i("span",{class:"bar-chart-empty",style:{color:u.fontColor,fontStyle:"italic"}},"-");const{totalWidth:y,labelAreaLeft:w,barAreaWidth:x,labelGap:S}=null!=f?f:$d(c,u.emPx),$=x/b,M=t=>w+(t-d.min)*$,{barY:_,barHeight:k}=dd(r),O=M(0),N=M(d.start),A=M(d.end),R=Math.min(N,A),L=Math.abs(A-N),T=Td(n,u),E=Wd(n,e,o,u),P=null==T?void 0:T.minuend.fillpattern,C="hatched"===P||"outlined"===P?Object.assign(Object.assign({},E),{fillpattern:P}):E,W=Dd(C,T?E===u.positive?"pos":"neg":Ld(n)),{stroke:D,strokeWidth:z}=T&&"hatched"===C.fillpattern?{stroke:C.stroke,strokeWidth:1}:zd(C),U=jd(e,d.kind,h,a,l,null!==T),F=A<N,G=F?R-S:R+L+S,j=F?"end":"start",I=pd(U,m,u.fontFamily,!1,v),B=S/2,Y=(F?G-I:G)-B,H=(F?G:G+I)+B,V=t=>t>Y&&t<H,X=void 0!==d.parentEnd?M(d.parentEnd):void 0,J=r/2-m/2,q=r/2+m/2,K=(t,i,s,e=0)=>t+e>Y&&t-e<H?[[i,Math.min(s,J)],[Math.max(i,q),s]].filter((([t,i])=>i>t)):[[i,s]],Q=-p.top,Z=r+p.bottom;return i("svg",{width:y,height:r,class:"cell-bar-chart waterfall-bar"+(T?" variance-waterfall":""),style:{overflow:"visible"}},i(Nd,{styles:u}),!T&&!V(O)&&i("line",{x1:O,y1:0,x2:O,y2:r,stroke:_d,"stroke-width":1*g}),void 0!==d.parentStart&&void 0!==d.parentEnd&&i("line",{x1:M(d.parentStart),y1:0,x2:M(d.parentStart),y2:r,stroke:_d,"stroke-width":1*g,"stroke-dasharray":`${2*g},${2*g}`}),void 0!==d.parentStart&&void 0!==X&&!V(X)&&i("line",{x1:X,y1:0,x2:X,y2:r,stroke:_d,"stroke-width":1*g,"stroke-dasharray":`${2*g},${2*g}`}),null===(s=d.connectors)||void 0===s?void 0:s.map((({at:t,part:s})=>K(M(t),"bottom"===s?_+k:Q,"top"===s?_:Z).map((([s,e])=>i("line",{class:"waterfall-connector",x1:M(t),y1:s,x2:M(t),y2:e,stroke:_d,"stroke-width":1*g}))))),L>0&&i("rect",{x:R,y:_,width:L,height:k,fill:W,stroke:D,"stroke-width":z*g}),T&&K(O,Q,Z,ud*u.emPx/2).map((([t,s])=>i("g",{transform:`translate(0,${t})`},i(Ed,{x:O,height:s-t,look:T,styles:u})))),i("text",{x:G,y:r/2,dy:"0.35em","text-anchor":j,fill:u.fontColor,"font-size":m,"font-family":u.fontFamily},U))},Bd=`IFNULL(${_a.ROWGROUP}, '')`;class Yd{constructor(t){this.groups=[_a.CATEGORY,_a.CATEGORYINDEX],At.OPT!==t.type&&At.OPTNOTOTAL!==t.type||this.groups.unshift(_a.OPERATION),t.grouped&&(this.groups.push(_a.ROWGROUP),this.groups.push(_a.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===_a.ROWGROUP?Bd:t)).toString()}select(){return this.groups.map((t=>t===_a.ROWGROUP?`${Bd} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==_a.CATEGORY))}toArray(){return this.groups}}function Hd(t,i){return Math.abs(t-i)<=1e-9*Math.max(1,Math.abs(t),Math.abs(i))}function Vd(t,i){const s=(t,i,s)=>{var e;t.connectors=[...null!==(e=t.connectors)&&void 0!==e?e:[],{at:i,part:s}]},e=(t,i,e,n)=>{s(t,n,"bottom"),i.forEach((t=>s(t,n,"through"))),s(e,n,"top")};let n=null;for(const s of t){if(null===s){n=null;continue}const{main:t,children:r}=s,o="anchor"===t.kind?t.end:t.start;if(n&&!s.gapAbove&&Hd(n.main.end,o)&&e(n.main,i?r:n.children,t,o),!s.gapAbove&&!s.gapBelow&&(r.forEach(((t,i)=>{i>0&&e(r[i-1],[],t,t.start)})),r.length>0)){const s=r[r.length-1];i?Hd(s.end,t.end)&&e(s,[],t,t.end):e(t,[],r[0],t.start)}n=s.gapBelow?null:s}}class Xd{constructor(){this.geometry=new Map,this.columns=new Set}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s),this.columns.add(i)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}has(t){return this.columns.has(t)}}function Jd(t){for(const i of t)for(const t of i){const i=t[_a.TYPE];if(i===Dt.SUM||i===Dt.GROUPSUM||i===Dt.DRILLELEMENT||i===Dt.PARTELEMENT)return!0}return!1}function qd(t){return`${t}__signed`}function Kd(t){var i;return"-"===(null!==(i=t[_a.OPERATION])&&void 0!==i?i:t.restOperation)?-1:1}function Qd(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);if(isNaN(n))return null;if((s===At.OPT||s===At.OPTNOTOTAL)&&t[_a.TYPE]===Dt.ENTRY){const s=t[qd(i)];return"number"==typeof s?s:Kd(t)*n}return n}function Zd(t,i){return null==t&&null==i?i:(null!=t?t:0)+(null!=i?i:0)}class tf{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(!zt.test(t))throw new Error(`invalid identifier "${t}"`);const e=[],n=[],r=[],o=this.scenariosSQL(!1),h=this.scenariosSQL(!0),a=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new Yd(this.config),u=this.config.interval===td?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var i,s;return null!==(s=null===(i=Ut(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===_a.ROWGROUP||t===_a.ROWGROUPINDEX||t.toUpperCase()in Ft)),g=p.filter((t=>t.toUpperCase()in Ft)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),m=p.length>0?p.map((t=>`${t} ${v}`)).toString():`${_a.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${_a.CATEGORY}) as ${_a.TOTALROWCOUNT} ${this.config.grouped?`, ${Bd} as ${_a.ROWGROUP}, FIRST(${_a.ROWGROUPINDEX}) as ${_a.ROWGROUPINDEX}${g}`:""}\n FROM ${i} ${this.config.grouped?`GROUP BY ${Bd} ORDER BY ${m}`:""}`);return 0===b.length||1===b.length&&0===(null!==(s=b[0][_a.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 (${_a.ROWGROUP} IS NULL OR ${_a.ROWGROUP} = '')`:`WHERE ${_a.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.hasRunningSum()&&this.accumulateGroupSums(r,[...new Set(this.exctractScenarioNames(h))]),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 Xs(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===At.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=[...new Set(this.exctractScenarioNames(t))],l=[];s.forEach((function(t){l.push(...o.exec(t,h))}));const c=new Map;l.forEach((t=>c.set(t[_a.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,a),r.forEach((t=>{this.toShares(t,c.get(t[_a.ROWGROUP]),a)})),this.injectDrillRowsToResultRows(r,e)}toShares(t,i,s){var e;const n=s=>t[s]/(i?i[s]:Number.NaN),r=new Map;for(const t of s){const i=new Xs(t);i.isValid&&r.set(t,n(i.base)-n(i.delta))}for(const i of s)t[i]=null!==(e=r.get(i))&&void 0!==e?e:n(i)}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=this.exctractScenarioNames(e).filter((t=>{var i;return null===(i=this.config.barColumns)||void 0===i?void 0:i.includes(t)})).map((t=>`, SUM(${t} * transformOperator(operation)) as ${qd(t)}`)).join(""),l=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type?`, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${a}`:"";i.push(`SELECT ${_a.ROWNR}, 1 as ${_a.ROWGROUPINDEX} , 'ENTRY' as ${_a.TYPE}, 'NO_GROUP' as ${_a.ROWGROUP}, ${this.bind(String(null!==(o=t.rowGroup)&&void 0!==o?o:""))} as restRowGroup, 'REST' as ${_a.CATEGORY}${l} ${h.length>0?", "+h:""} FROM (SELECT ROWNUM() AS ${_a.ROWNR}, ${i.length} as ${_a.ROWGROUPINDEX} , 'ENTRY' as ${_a.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${_a.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 ${_a.ROWNR},\n ${t.length} as ${_a.ROWGROUPINDEX},\n 'ENTRY' as ${_a.TYPE},\n ${this.bind(String(i.rowGroup||"NO_GROUP"))} as ${_a.ROWGROUP},\n '${_a.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 ${_a.ROWNR},\n ${i.length} as ${_a.ROWGROUPINDEX},\n 'GROUPHEAD' as ${_a.TYPE},\n ${s} as ${_a.ROWGROUP} ${this.config.showGroupTitle?`,${e} as ${_a.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return At.SUM===this.config.type||At.SUMNOTOTAL===this.config.type||At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type}hasRunningSum(){return this.config.runningSum&&this.config.grouped&&this.hasGroupSum()&&0===this.config.categoryThereOf.size}accumulateGroupSums(t,i){const s={};for(const e of t)for(const t of e)if("GROUP_SUM"===t[_a.TYPE])for(const e of i)s[e]=Zd(s[e],t[e]),t[e]=s[e]}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 ${_a.ROWGROUPINDEX},\n '=' as ${_a.OPERATION},\n ${o} as ${_a.ROWGROUP},\n ROWNUM() AS ${_a.ROWNR},\n 'GROUP_SUM' as ${_a.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `),i.push(`SELECT ${t.length} as ${_a.ROWGROUPINDEX},\n '=' as ${_a.OPERATION},\n ${o} as ${_a.ROWGROUP},\n ROWNUM() AS ${_a.ROWNR},\n 'GROUP_SUM' as ${_a.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `)}}createTotalSumRow(t,i,s){var e;if(At.SUM===this.config.type||At.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 ${_a.ROWGROUPINDEX},\n ${this.bind(n)} as ${_a.ROWGROUP},\n '=' as ${_a.OPERATION},\n 'SUM' as ${_a.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${_a.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${_a.ROWGROUP},\n '=' as ${_a.OPERATION},\n 'SUM' as ${_a.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[_a.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[_a.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[_a.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+=` ${_a.CATEGORY} = ${this.bind(e.category)}`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(o+=` ${r?"":"AND"} ${_a.ROWGROUP} = ${this.bind(e.rowGroup)}`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(o+=` ${r?"":"AND"} ${_a.SUBCATEGORY} = ${this.bind(e.subCategory)}`),o+=")",n.push(`SELECT ROWNUM() AS ${_a.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${_a.TYPE},\n ${_a.CATEGORY},\n ${_a.SUBCATEGORY},\n ${this.drillRowGroup} as ${_a.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.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[_a.TYPE]&&i.forEach(((i,s)=>{var e;t[s]=null!==(e=nt(t[s],t[i]))&&void 0!==e?e:et}))}))}))}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[_a.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===Zu||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const o="##",h=`(SELECT *, ${id(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.scenariosSQL(!1),l=this.scenariosSQL(!0),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new Yd(this.config),f=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(At.SUM===this.config.type||At.SUMNOTOTAL===this.config.type||At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type),p=this.checkConfigForPartOf()&&this.config.type!==At.LIST,g=t=>this.exec(t),m=t=>(this.config.scenarios.forEach((i=>{const s=new Xs(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=nt(t[s],t[i]))&&void 0!==e?e:et})),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=ed(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=ed(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 ${Bd} as ${_a.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY ${Bd}, __interval`):[],S=new Map;if(x.forEach((t=>S.set(`${t.rowGroup}${o}${ed(t.__interval)}`,t))),v&&this.hasRunningSum()){const i=[...new Set(this.exctractScenarioNames(l))],s=t.flat().filter((t=>"GROUP_SUM"===t.type));for(const t of new Set(x.map((t=>ed(t.__interval))))){let e;for(const n of s){const s=S.get(`${n.rowGroup}${o}${t}`);if(s){null!=e||(e={});for(const t of i)e[t]=Zd(e[t],s[t])}e&&b(n,m(Object.assign({},e)),t)}}}else if(v)for(const i of x){const s=ed(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 $=At.SUM===this.config.type||At.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(ed(t.__interval),t))),$)for(const i of M){const s=ed(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 ${_a.ROWGROUP}, ${_a.CATEGORY}, ${_a.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.SUBCATEGORY}, __interval`))}));for(const s of i){const i=ed(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 (${_a.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`),i+=")"}));const s=g(`SELECT ${_a.CATEGORY}, ${this.config.grouped?`${_a.ROWGROUP}`:`'SUM_TOTAL' as ${_a.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${i}\n GROUP BY ${_a.ROWGROUP}, ${_a.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${o}${t.category}${o}${ed(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=ed(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${o}${s}`):_.get(s);this.toShares(i,e,c),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+=` ${_a.CATEGORY} = ${this.bind(t.category)}`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${_a.SUBCATEGORY} = ${this.bind(t.subCategory)}`),s+")"}scenariosSQL(t){const i=this.config.scenarios,s=i.map((i=>this.translateScenarioSQL(i,t,this.config.type)));if(this.checkConfigForPartOf()&&this.config.type!==At.LIST){const e=new Set;for(const t of i){const i=new Xs(t);i.isValid&&e.add(i.base).add(i.delta)}for(const n of e)i.includes(n)||s.push(this.translateScenarioSQL(n,t,this.config.type).split(", COUNT(")[0])}return s.toString()}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 Xs(t);if(At.OPT===s||At.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!==At.OPT&&this.config.type!==At.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?Bd:_a.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=Gt.ASC===t.direction?Gt.DESC:Gt.ASC,s=new Map;t.hierarchy.forEach(((t,i)=>{const e=Ut(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=Ut(t))||void 0===i?void 0:i.kind;return"scenario"===s||"variance"===s}));e&&(this.sortSelect+=`, CASE WHEN ${_a.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=At.OPT===this.config.type||At.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",n=void 0===i?"":`TRIM(CAST(${id(td)} 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 Xs(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 ${_a.ROWGROUP}`,o="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${_a.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${_a.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${_a.ROWGROUP} `,o="1"),n+=")"})),e.push(`SELECT ${o} AS ${_a.ROWNR},\n 'PARTELEMENT' as ${_a.TYPE},\n ${_a.CATEGORY},\n ${r},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${this.drillRowGroup}, ${_a.CATEGORY}, ${_a.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 sf{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)?Zs(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 ad(l?1:0,0,Dt.HEADER),u=new ad(l?2:1,0,Dt.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);c.createElement(i?s.get(i.label)||i.label:Oa.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 ad(0,0,Dt.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=Oa.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=Oa.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s,e=0){let n=[{name:_a.CATEGORY,group:_a.CATEGORY,type:_a.CATEGORY,order:void 0}];At.OPT!==t&&At.OPTNOTOTAL!==t||(n=[{name:_a.OPERATION,group:_a.OPERATION,type:_a.OPERATION,order:void 0},{name:_a.CATEGORY,group:_a.CATEGORY,type:_a.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 tf(t,i);var a;this.dateBuckets=(a=t.interval)!==Zu&&a!==td,this.unsignedEntries=At.OPT===t.type||At.OPTNOTOTAL===t.type;const l=h.execute(s,e);this.hasBlankRowGroup=h.hasBlankRowGroup;const c=this.calculateColumnStatistics(l,t.barColumns,t.interval!==Zu),u=t.thereOfPosition===Nt.ABOVE,d=null!==(n=t.barColumns)&&void 0!==n?n:[],f=d.filter((t=>t.toUpperCase().trim()in Ft)),v=[...f.length>0&&Jd(l)?f:[],...t.varianceWaterfall?d.filter((t=>"d"===new Xs(t).type)):[]],p=v.length>0&&t.interval===Zu&&0===t.categoryThereOf.size?function(t,i,s,e=!1,n=!1){const r=new Xd,o=s===At.OPT||s===At.OPTNOTOTAL;for(const h of i){const i=new Xs(h).isValid;let a,l=0,c=0;const u=[],d=[];let f=null;const v=(t,i)=>(u.push(i),r.set(t,h,i),i),p=t=>{f=t&&{main:t,children:[],gapAbove:!1,gapBelow:!1},d.push(f)};for(const r of t)for(const t of r){const r=t[_a.TYPE];if(r===Dt.GROUPHEAD){e||(l=0),a=void 0,p(null);continue}const u=Qd(t,h,s);if(r===Dt.ENTRY){if(null===u){a=void 0,p(null);continue}p(v(t,{start:l,end:l+u,min:0,max:0,kind:"cascade"})),a={start:l,end:l+u,sign:o?Kd(t):1},c=a.start,l+=u}else if(r===Dt.SUM||r===Dt.GROUPSUM){if(null===u){a=void 0,p(null);continue}p(v(t,{start:0,end:u,min:0,max:0,kind:"anchor"})),a={start:0,end:u,sign:1},c=0,l=r!==Dt.GROUPSUM||e?u:0}else if(!i||r!==Dt.DRILLELEMENT&&r!==Dt.PARTELEMENT){if(r===Dt.DRILLELEMENT){if(null===u||void 0===a)continue;const i=c+(Math.sign(a.end-a.start)||1)*Math.abs(u);v(t,{start:c,end:i,min:0,max:0,kind:"thereof",parentStart:a.start,parentEnd:a.end}),c=i}else if(r===Dt.PARTELEMENT){if(null===u||void 0===a)continue;const i=c+u*(a.end-a.start);v(t,{start:c,end:i,min:0,max:0,kind:"partof",parentStart:a.start,parentEnd:a.end}),c=i}}else if(r===Dt.DRILLELEMENT&&null!==u&&void 0!==a&&f){const i=c+a.sign*u;f.children.push(v(t,{start:c,end:i,min:0,max:0,kind:"thereof"})),c=i}else f&&(n&&r===Dt.DRILLELEMENT?f.gapAbove=!0:f.gapBelow=!0)}i&&Vd(d,n);let g=0,m=0;for(const t of u)g=Math.min(g,t.start,t.end),m=Math.max(m,t.start,t.end);for(const t of u)t.min=g,t.max=m}return r}(l,v,t.type,h.hasRunningSum(),u):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,p,u));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[_a.TYPE];if(r!==Dt.SUM&&r!==Dt.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,u=!1){var d,f,v;const p=[];let g,m,b=-1;for(const y of e){const w=y[_a.ROWGROUP],x=""===w?"-":w,S=y[_a.SUBCATEGORY],$=y[_a.TYPE],M=y[_a.ROWNR]>=2;m=null!==(f=null!==(d=y.operation)&&void 0!==d?d:y.restOperation)&&void 0!==f?f:m;const _=u&&$===Dt.DRILLELEMENT&&void 0!==g&&g[_a.CATEGORY]===y[_a.CATEGORY]&&("NO_GROUP"===g[_a.ROWGROUP]||g[_a.ROWGROUP]===w),k=this.createDetailRow($,r+=1,n,e.length);k.key=this.rowKey(y);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(y,e),r=null!==(v=null==a?void 0:a.includes(e.type))&&void 0!==v&&v,u=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(y,e.type):void 0,d=$===Dt.PARTELEMENT&&new Xs(e.type).isValid,f=r&&!d,p=f?null==l?void 0:l.get(e.type):void 0;k.createElement(d&&s===Ot.PERCENT?"-":this.translateSumCellLabel(t,i,n,x,S,$,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),_?null:this.translateCellPrefix(i,$,e.type),this.translateScenarioCSS(e.type,n,m),M,o,null==h?void 0:h.value,f,p,1,u);const g=k.elements[k.elements.length-1];this.dateBuckets&&void 0!==e.bucket&&(g.date=cs(e.bucket));const b=new Xs(e.type);b.isValid&&(g.direction=this.resolveDirection(b,m))}_?(k.cssStyle="ofit-above",p[b].cssStyle="ofit-sum",p.splice(b,0,k),b+=1):($===Dt.ENTRY&&(b=p.length,g=y),p.push(k))}return p}rowKey(t){var i;const s=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case Dt.ENTRY:return{rowGroup:s,category:t.category,subCategory:t.subCategory};case Dt.DRILLELEMENT:return{rowGroup:s,category:t.category,subCategory:null!==(i=t.rawSubCategory)&&void 0!==i?i:t.subCategory};case Dt.GROUPSUM:return{rowGroup:s,row:"subtotal"};case Dt.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 Dt.GROUPHEAD:return new ad(i,s,Dt.HEADER);case Dt.SUM:case Dt.GROUPSUM:return new ad(e+2,s,Dt.SUM);case Dt.DRILLELEMENT:return new ad(e+2,s,Dt.DRILLELEMENT);case Dt.PARTELEMENT:return new ad(e+2,s,Dt.PARTELEMENT);default:return new ad(i,s,Dt.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===Lt.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,o)?t===Lt.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,o)?t===Lt.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,o)?t===Lt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,o)?t===Lt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s||s===et?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 Xs(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 Js(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 Xs(t);return i===Ot.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 ef{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new se,this.db=i,this.dataSetFactory=new sf(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=jt.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=jt.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=jt.DIRTY,this.fromExpr=M(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=jt.UP_TO_DATE}getHeader(){return this.state===jt.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===jt.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===jt.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===Zu||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=Zu:(this.config.interval=function(t,i,s){var e;if(s!==at.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=nd(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?at.DAY:(new ut).calculateDistanceType(w.fromMillis(r),w.fromMillis(o))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){if(s===td){const e=t.exec(`SELECT ${id(s)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${i}`),n=new Set,r=new Map,o=[];for(const t of e){const i=ed(t.__interval);n.has(i)||(n.add(i),o.push({key:i,label:0===i.length?"-":i}));const s=sd(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 ${id(s)} as __interval FROM ${i}`),r=new Set,o=[];for(const t of n){const i=nd(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 ut;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=Zu))}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=>Ut(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),h=this.config.interval===td?null==o?void 0:o.bucket:void 0,a=(t,i)=>{var e;return null==o||(null===(e=Ut(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!==jt.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=Ut(t))||void 0===i?void 0:i.bucket})).filter((t=>void 0!==t));if(0===s.length)return;if(this.config.interval!==td)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!==jt.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 nf{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=Ot.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereOf=[],this.thereOfPosition=Nt.BELOW,this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new st(new Tl).default(),this.type=At.LIST,this.limit=0,this.i18n=Lt.ALL,this.categoryWidth=Tt.W25,this.measureScale=new La,this.measureUnit="",this.measureType=Et.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class rf{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 nf;return R.isString(t.title)&&(i.title=t.title),R.isArray(t.scenarios)&&(i.scenarios=it.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.runningSum)&&(i.runningSum=t.runningSum),R.isBoolean(t.varianceWaterfall)&&(i.varianceWaterfall=t.varianceWaterfall),t.thereOfPosition===Nt.ABOVE&&(i.thereOfPosition=Nt.ABOVE),R.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),R.isArray(t.thereOf)&&(i.thereOf=it.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),R.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),R.isArray(t.partOf)&&(i.partOf=it.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 nf}}class of{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class hf{constructor(){}adapt(t){const i=new of;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 of}}const af=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=Ot.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereof=[],this.thereofPosition=Nt.BELOW,this.partof=[],this.order={hierarchy:[],direction:Gt.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=At.LIST,this.categoryWidth=Tt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=Lt.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=Et.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 oc,this.blockStarts=new Set,this.barColumnLayouts=new Map,this.waterfallGeometries=new Map,this.relayout=()=>{(this.barColumnLayouts.size>0||this.waterfallGeometries.size>0)&&n(this)},l(this),this.componentStyle=N(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:li(h,t)}),a&&r.regions.push({id:"body",rect:li(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:li(o,t),point:ls(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:li(h,t),point:ls(h)};l.point&&(l.content=gi(h,t),l.contentSign=mi(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:li(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",{class:{"grouped-list":this.groupedList()},style:{"--bn-block-gap":.6*this.emPx()+"px"}},i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map(((t,s,e)=>i("th",{colSpan:t.colSpan,class:`${t.cssStyle}${this.isBarColumn(t.key)?" barColumn":""}${this.blockStartClass(e,s)}`},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},as(t.key,"element")),null==t?void 0:t.getCells().map(((s,e,n)=>{var o,h,a,l,c;return i("td",Object.assign({colSpan:s.colSpan,class:(s.type?`${this.cellClass(s,r)} ${s.type}`:s.cssStyle)+this.blockStartClass(n,e)},t.key&&null!=s.value&&""!==s.value&&"-"!==s.value?as(Object.assign(Object.assign({},t.key),{date:s.date,scenario:s.key}),"element"):{}),null!=s.prefix?i("span",{class:this.cellClass(s,r)+" "+s.prefixStyle},s.drawPrefix()):"",!s.isBarChart||!s.columnStats||s.value===et||!this.showGroupTitle&&t.type===Dt.HEADER||void 0===s.waterfall&&t.type===Dt.SUM||void 0!==s.direction&&s.waterfall&&s.waterfall.max===s.waterfall.min?s.draw(this.componentDataFormatDigits,r):void 0!==s.waterfall?i(Id,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===s.direction,measureScale:cf(s),locale:r,decimalDigits:uf(s,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall,geometry:this.waterfallGeometries.get(s.key),bold:lf(t),connectorReach:this.connectorReach(t)}):i(Gd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:"pos"===s.direction,measureScale:cf(s),locale:r,decimalDigits:uf(s,this.componentDataFormatDigits),percentDigits:null!==(h=null===(o=this.barColumnLayouts.get(s.key))||void 0===o?void 0:o.percentDigits)&&void 0!==h?h:this.componentDataFormatDigits.percent,percentSign:null===(a=this.barColumnLayouts.get(s.key))||void 0===a?void 0:a.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(l=this.barColumnLayouts.get(s.key))||void 0===l?void 0:l.labels,sideMax:null===(c=this.barColumnLayouts.get(s.key))||void 0===c?void 0:c.sideMax,bold:lf(t),styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,i,s,e,n,r,o,h,a,l,c;this.stores||(this.stores=u(this.element));const d=this.stores.db.db;this.componentDataFormatDigits=(new hc).adapt(this.dataFormatDigits);try{const i=this.prepareConfig(d);this.table=new ef(new se(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===(c=this.errors)||void 0===c||c.remove(t);this.blockStarts=this.collectBlockStarts(),this.barColumnLayouts=this.collectBarColumnLayouts(),this.waterfallGeometries=this.collectWaterfallGeometries(),this.barChartStyles=this.prepareBarChartStyles()}collectBlockStarts(){const t=new Set;if(!this.table||this.table.hasNoData())return t;const i=this.table.getColumns().map((t=>{var i;const s=new Xs(t.type),e=s.isValid?`${s.base}_${s.delta}`:/^(ac|pp|fc|pl)\d/i.test(t.type)?"scenario":"rowheader";return`${null!==(i=t.bucket)&&void 0!==i?i:""}|${e}`}));return i.forEach(((s,e)=>{e>0&&s!==i[e-1]&&t.add(e)})),t}blockStartClass(t,i){let s=0;for(let e=0;e<i;e++)s+=t[e].colSpan;return this.blockStarts.has(s)?" block-start":""}groupedList(){return!0===this.grouped&&this.type!==At.OPT&&this.type!==At.OPTNOTOTAL}isBarColumn(t){return this.barColumns.includes(t)}cellClass(t,i){return void 0!==t.direction&&t.roundsToZero(this.componentDataFormatDigits,i)?t.cssStyle.replace(/^(pos|neg)_\w+/,"zero"):t.cssStyle}prepareConfig(t){var i,s,e;const n=M(t,this.tableName,this.filter);return new rf(new hf,new Tl,new st(new Tl,!0),t,n,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereOf:this.thereof,thereOfPosition:this.thereofPosition,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,categoryIntervalPosition:this.categoryIntervalPosition,locale:(null===(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,_,k,O,N;const A=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,R=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==A?void 0:A.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(o=null==A?void 0:A.pos)||void 0===o?void 0:o.fill)||"#008f96",fillpattern:he(null===(h=null==A?void 0:A.pos)||void 0===h?void 0:h.fillpattern)||"solid"},negative:{stroke:(null===(a=null==A?void 0:A.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(l=null==A?void 0:A.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:he(null===(c=null==A?void 0:A.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==A?void 0:A.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==A?void 0:A.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:he(null===(f=null==A?void 0:A.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:te({ac:{stroke:(null===(v=null==R?void 0:R.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===(p=null==R?void 0:R.ac)||void 0===p?void 0:p.fill)||"#404040",fillpattern:he(null===(g=null==R?void 0:R.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==R?void 0:R.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==R?void 0:R.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:he(null===(y=null==R?void 0:R.pp)||void 0===y?void 0:y.fillpattern)||"solid"},fc:{stroke:(null===(w=null==R?void 0:R.fc)||void 0===w?void 0:w.stroke)||"#404040",fill:(null===(x=null==R?void 0:R.fc)||void 0===x?void 0:x.fill)||"#ffffff",fillpattern:he(null===(S=null==R?void 0:R.fc)||void 0===S?void 0:S.fillpattern)||"hatched"},pl:{stroke:(null===($=null==R?void 0:R.pl)||void 0===$?void 0:$.stroke)||"#404040",fill:(null===(M=null==R?void 0:R.pl)||void 0===M?void 0:M.fill)||"#ffffff",fillpattern:he(null===(_=null==R?void 0:R.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new se(this.ruleSetConfig)),fontColor:(null===(k=t.global)||void 0===k?void 0:k.fontColor)||"#000000",fontSize:((null===(O=t.global)||void 0===O?void 0:O.fontSizePx)||13.3333)*ld*this.scaleFactor,emPx:((null===(N=t.global)||void 0===N?void 0:N.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*ld;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=xd(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*ld;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=8*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!==Dt.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:[],{cell:s,bold:lf(i)}]));const o=this.emPx(),h=o*ld,a=8*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((({cell: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=Pd(o);for(const{cell:e,bold:u}of i){const i=e.value,d=i>0||0===i&&a?"pos":"neg",f=Ad(i,s,cf(e),l,t,n,uf(e,this.componentDataFormatDigits));o[d]=Math.max(null!==(r=o[d])&&void 0!==r?r:0,pd(f,h,c,s,u))}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)&&!yd(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}connectorReach(t){const i=this.emPx(),s=this.groupedList()?1:.5;return{top:.1*i,bottom:t.type===Dt.SUM?s*i:0}}collectWaterfallGeometries(){var t,i,s,e;const n=new Map;if(!this.table||this.table.hasNoData())return n;const r=this.emPx(),o=r*ld,h=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,a=this.labelFontFamily(),l=new Map;for(const t of this.table.getBody())for(const i of t.getCells()){if(!i.isBarChart||!i.columnStats||void 0===i.waterfall)continue;if("number"!=typeof i.value||isNaN(i.value))continue;const{start:s,end:n,min:r,max:c,kind:u}=i.waterfall,d=jd(i.value,u,cf(i),h,uf(i,this.componentDataFormatDigits),void 0!==i.direction),f=null!==(e=l.get(i.key))&&void 0!==e?e:{min:r,max:c,labels:[]};f.labels.push({end:n,pointsLeft:n<s,width:pd(d,o,a,!1,lf(t))}),l.set(i.key,f)}for(const[t,i]of l)n.set(t,$d(this.barColumnMaxWidth,r,i));return n}get element(){return e(this)}};function lf(t){return t.type===Dt.SUM||"ofit-sum"===t.cssStyle}function cf(t){return"percentpoint"===t.type?.01:t.measureScale}function uf(t,i){return"percentpoint"===t.type?i.percent:"decimal"===t.type?i.decimal:void 0}af.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,td.zero{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}tr.partof td.percentpoint{font-style:italic}tr.partof td.percentpoint:after{content:"%p"}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.barColumn{text-align:center}td.block-start,th.block-start{border-left:var(--bn-block-gap, 0) solid transparent;clip-path:inset(-100em -100em -100em var(--bn-block-gap, 0))}.category-w100.block-start{min-width:calc(100em + var(--bn-block-gap, 0px));max-width:calc(100em + var(--bn-block-gap, 0px))}.category-w50.block-start{min-width:calc(50em + var(--bn-block-gap, 0px));max-width:calc(50em + var(--bn-block-gap, 0px))}.category-w25.block-start{min-width:calc(25em + var(--bn-block-gap, 0px));max-width:calc(25em + var(--bn-block-gap, 0px))}.category-w20.block-start{min-width:calc(20em + var(--bn-block-gap, 0px));max-width:calc(20em + var(--bn-block-gap, 0px))}.category-w15.block-start{min-width:calc(15em + var(--bn-block-gap, 0px));max-width:calc(15em + var(--bn-block-gap, 0px))}.category-w10.block-start{min-width:calc(10em + var(--bn-block-gap, 0px));max-width:calc(10em + var(--bn-block-gap, 0px))}.category-w5.block-start{min-width:calc(5em + var(--bn-block-gap, 0px));max-width:calc(5em + var(--bn-block-gap, 0px))}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}table.grouped-list tr.sum td{padding-bottom:1em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.sum td.pos_pos,tr.sum td.pos_neg,tr.sum td.neg_pos,tr.sum td.neg_neg,tr.ofit-sum td.pos_pos,tr.ofit-sum td.pos_neg,tr.ofit-sum td.neg_pos,tr.ofit-sum td.neg_neg{color:inherit}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.cell-bar-chart),tr.partof td:has(.cell-bar-chart),tr.share td:has(.cell-bar-chart){padding:0 0.4166666667em}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';const df=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",E(this),l(this),this.t=ti(this).t,this.errors=c(this),this.componentStyle=N(this),this.ruleSetConfig=Ms(this)}validateScenario(t){const i="WARN_scenarios",s=V(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=X(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=F(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";G(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=It(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";Bt(t)||L(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";Bt(t)||L(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";ot(t)||L(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";Yt(t)||L(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=g,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(),...ie(this.ruleSetConfig("user"))])}prepareI18nMode(){return Lt.META}prepareLocale(){return u(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return L(this.order)||L(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:I[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return L(this.dateStart)&&L(this.dateEnd)||L(this.dateLink)?null:{start:w.fromISO(this.dateStart,{zone:"utc"}),end:w.fromISO(this.dateEnd,{zone:"utc"}),format:at[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Ht[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){if(L(this.measures))return[];try{return JSON.parse(this.measures)}catch(t){return[]}}prepareScenarios(){var t,i,s,e;if(L(this.scenarios)&&L(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 L(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":`${this.titleFontSize>0?this.titleFontSize:(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:"999f282ecc2901b62f051e0501da7dd41f44a30a",style:t},i("bn-title-renderer",{key:"2c58cbb472fc807a83503e7789babce4b17b1081",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}]}}};df.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 ff{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===Lt.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 ut;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(" ",Oa.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 vf{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=Lt.ALL,this.intervalSpanLimit=32,this.locale="de"}}class pf{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new vf;return R.isString(t.businessunit)&&(i.businessunit=t.businessunit),R.isArray(t.measures)&&(i.measures=it.adaptArray(t.measures,this.measureEntryAdapter)),R.isArray(t.scenarios)&&(i.scenarios=it.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 vf}}var gf;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(gf||(gf={}));class mf{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new vf,this.state=gf.DIRTY,this.ruleSet=t||new se,this.dataSetFactory=new ff,this.state=gf.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new se}setI18n(t){this.state=gf.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 gf.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=gf.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=gf.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class bf{constructor(t="",i=""){this.name=t,this.unit=i}}class yf{construnctor(){}adapt(t){const i=new bf;return R.isString(t.name)&&(i.name=t.name),R.isString(t.unit)&&(i.unit=t.unit),i}default(){return new bf("","")}}class wf{constructor(t=w.now(),i=w.now(),s=at.AUTO,e=Ht.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class xf{construnctor(){}adapt(t){const i=new wf;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 wf}}const Sf=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:I.ASC},this.i18n=new Map,this.i18nMode=Lt.ALL,this.locale="de",this.title=new mf(new se),l(this)}render(){return i("div",{key:"ecc33a660538732ceea3e4620afabfcb8ffbce95"},i("div",{key:"cb1c3b074817a4c0647419fdc0f2b94c113ebc09",innerHTML:Vt(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 mf(new se(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 se(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new pf(new yf,new xf,new st(new Tl),new Tl).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})}};Sf.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 $f=["*","/","+","-","x","÷","none"];function Mf(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function _f(t,i,s){return t.find((t=>t.from===i&&t.to===s))}function kf(t){return 2*(t-1)+1}function Of(t){return 2*(t-1)+1}function Nf(t){return t<=1?1:2*(t-1)+1}function Af(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 Rf(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 Lf(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 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 Pf(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 Cf(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 Wf=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&&$f.includes(o.operator)||i.push(`edges[${s}]: 'operator' must be one of: ${$f.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";!rt(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";!rt(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),l(this),this.errors=c(this),this.componentStyle=N(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=di(this.element),v=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),p={version:bi,tag:this.element.localName,id:ci(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:li(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:ai(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:li(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:li(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:li(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:li(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=$s(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,Af(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=Xt(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=Jt(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(kf(i.gridColumn)),"grid-row":`${Of(i.gridRow)} / span ${Nf(i.gridRowSpan)}`,"align-self":"center"}:{"grid-row":String(Of(i.gridRow)),"grid-column":`${kf(i.gridColumn)} / span ${s=i.gridColumnSpan,Nf(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=Rf(n,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const i=l.indexOf(t.from);c=Lf(h,this.direction,i,l.length)}else c=Rf(h,!1,this.direction);const{path:u}=Tf(a,c,this.edgeStyle,this.direction,o.get(t.from)),d=Cf(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=_f(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:Mf(c.operator),v=Pf(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","data-bn-fit-content":"",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}]}}};Wf.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{Ji as bn_annotation_layer,qi as bn_annotation_list,Ki as bn_asset,Qi as bn_body,Zi as bn_card,Vs as bn_chart_bubble,Qa as bn_chart_bubble_renderer,hl as bn_chart_bullet,gl as bn_chart_bullet_renderer,bl as bn_chart_scatter,Sl as bn_chart_scatter_renderer,$l as bn_chart_structure,ac as bn_chart_structure_renderer,lc as bn_chart_time,Ic as bn_chart_time_renderer,Bc as bn_component_style,su as bn_context,Wu as bn_dataset,Du as bn_datasource,zu as bn_footer,Xu as bn_layout_card,Ju as bn_layout_page,qu as bn_message,Ku as bn_page,Qu as bn_scaling_group,rd as bn_table,af as bn_table_renderer,df as bn_title,Sf as bn_title_renderer,Wf as bn_tree}