@bino-bi/bn-template-engine 1.0.0-next.53 → 1.0.0-next.55

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 (112) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-3379df20.entry.js +1 -0
  3. package/dist/bn-template-engine/{p-9a24e486.entry.js → p-471ea1b2.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-fdf42a77.entry.js → p-776e091f.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-B6SpWzpW.js +1 -0
  6. package/dist/bn-template-engine/{p-NxJ6P79y.js → p-BXkVoFbt.js} +1 -1
  7. package/dist/bn-template-engine/{p-BL07yV8P.js → p-CZmA8CIL.js} +1 -1
  8. package/dist/bn-template-engine/{p-Dvlw60RF.js → p-CzzF-PBk.js} +1 -1
  9. package/dist/bn-template-engine/{p-Bvunba5p.js → p-DBRtHV59.js} +1 -1
  10. package/dist/bn-template-engine/{p-b75a4b52.entry.js → p-e905e4ee.entry.js} +1 -1
  11. package/dist/bn-template-engine/{p-150bdb68.entry.js → p-ef63af53.entry.js} +1 -1
  12. package/dist/bn-template-engine/{p-ddc1b2a9.entry.js → p-f62c59b0.entry.js} +1 -1
  13. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +34 -19
  14. package/dist/cjs/bn-grid.cjs.entry.js +3 -3
  15. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  17. package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
  18. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  19. package/dist/cjs/{localFrame-C4RBw_zT.js → localFrame-J1QUlhHH.js} +1 -1
  20. package/dist/cjs/{withBodyObserver-CIGVLQEB.js → withBodyObserver-DhrwVmn_.js} +1 -1
  21. package/dist/cjs/{withHasError-CZFrIJw0.js → withHasError-DOXAxUCF.js} +2 -0
  22. package/dist/cjs/{withStyled-BISQLGLe.js → withStyled-CHR4d8Hl.js} +1 -1
  23. package/dist/cjs/{withTranslation-B7T30EVU.js → withTranslation-Vuxqw9J7.js} +2 -2
  24. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +6 -2
  25. package/dist/collection/components/bn-annotation-layer/utils/marks.js +7 -4
  26. package/dist/collection/components/bn-annotation-list/bn-annotation-list.js +6 -2
  27. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +2 -1
  28. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +1 -0
  29. package/dist/collection/components/bn-chart-structure/utils/elements/Axis.js +1 -1
  30. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +2 -0
  31. package/dist/collection/stores/componentStyles.js +2 -0
  32. package/dist/collection/utils/layoutState/svgChartElements.js +4 -4
  33. package/dist/components/bn-annotation-layer.js +1 -1
  34. package/dist/components/bn-annotation-list.js +1 -1
  35. package/dist/components/bn-asset.js +1 -1
  36. package/dist/components/bn-body.js +1 -1
  37. package/dist/components/bn-card.js +1 -1
  38. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  39. package/dist/components/bn-chart-bubble.js +1 -1
  40. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  41. package/dist/components/bn-chart-bullet.js +1 -1
  42. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  43. package/dist/components/bn-chart-scatter.js +1 -1
  44. package/dist/components/bn-chart-structure-renderer.js +1 -1
  45. package/dist/components/bn-chart-structure.js +1 -1
  46. package/dist/components/bn-chart-time-renderer.js +1 -1
  47. package/dist/components/bn-chart-time.js +1 -1
  48. package/dist/components/bn-component-style.js +1 -1
  49. package/dist/components/bn-context.js +1 -1
  50. package/dist/components/bn-dataset.js +1 -1
  51. package/dist/components/bn-datasource.js +1 -1
  52. package/dist/components/bn-footer.js +1 -1
  53. package/dist/components/bn-grid.js +1 -1
  54. package/dist/components/bn-image.js +1 -1
  55. package/dist/components/bn-internationalization.js +1 -1
  56. package/dist/components/bn-layout-card.js +1 -1
  57. package/dist/components/bn-layout-page.js +1 -1
  58. package/dist/components/bn-message.js +1 -1
  59. package/dist/components/bn-page.js +1 -1
  60. package/dist/components/bn-ruleset.js +1 -1
  61. package/dist/components/bn-scaling-group.js +1 -1
  62. package/dist/components/bn-table-renderer.js +1 -1
  63. package/dist/components/bn-table.js +1 -1
  64. package/dist/components/bn-text.js +1 -1
  65. package/dist/components/bn-title.js +1 -1
  66. package/dist/components/bn-tree.js +1 -1
  67. package/dist/components/p-5LbdDgZ5.js +1 -0
  68. package/dist/components/{p-dSUX43yf.js → p-BAvpRnjI.js} +1 -1
  69. package/dist/components/{p-DRU71K0s.js → p-BCTmWVaW.js} +1 -1
  70. package/dist/components/{p-Bp5Xj4-s.js → p-BPvwrhvq.js} +1 -1
  71. package/dist/components/{p-CZSp0rSS.js → p-BQD7EWUn.js} +1 -1
  72. package/dist/components/p-BY1Y1Ipv.js +1 -0
  73. package/dist/components/{p-DdvG1D18.js → p-Bmb0YBzz.js} +1 -1
  74. package/dist/components/{p-CiljAoC5.js → p-BpyLanO3.js} +1 -1
  75. package/dist/components/p-CFF7b9FT.js +1 -0
  76. package/dist/components/p-CFY-zEXs.js +1 -0
  77. package/dist/components/{p-DMAaBt7n.js → p-CTX2pUU7.js} +1 -1
  78. package/dist/components/{p-DKcw-1ot.js → p-CThV2et_.js} +1 -1
  79. package/dist/components/{p-CHJ6WE0l.js → p-CWSjn_DC.js} +1 -1
  80. package/dist/components/{p-jEqo8YD5.js → p-ChMe_jnA.js} +1 -1
  81. package/dist/components/p-ClFDt6Bk.js +1 -0
  82. package/dist/components/{p-LHIKI9Dp.js → p-D7pKezNW.js} +1 -1
  83. package/dist/components/{p-NdDdfez6.js → p-Dmsa7xm_.js} +1 -1
  84. package/dist/components/{p-BOwmXBm-.js → p-LB2R8XbL.js} +1 -1
  85. package/dist/components/{p-JG4Sx1lE.js → p-NkLVO7n9.js} +1 -1
  86. package/dist/components/{p-D65TnLS9.js → p-OR6uR6gy.js} +1 -1
  87. package/dist/components/{p-2t-lysdb.js → p-YuXVqXS_.js} +1 -1
  88. package/dist/components/{p-4xaxuPVU.js → p-tz4QGm3s.js} +1 -1
  89. package/dist/esm/bn-annotation-layer_30.entry.js +34 -19
  90. package/dist/esm/bn-grid.entry.js +3 -3
  91. package/dist/esm/bn-image.entry.js +2 -2
  92. package/dist/esm/bn-internationalization.entry.js +2 -2
  93. package/dist/esm/bn-ruleset.entry.js +2 -2
  94. package/dist/esm/bn-text.entry.js +3 -3
  95. package/dist/esm/{localFrame-WNu1bAPm.js → localFrame-wBZfmzjd.js} +1 -1
  96. package/dist/esm/{withBodyObserver-wJgSN1Pj.js → withBodyObserver-DgAvBnkB.js} +1 -1
  97. package/dist/esm/{withHasError-BDWEBrrb.js → withHasError-CRNW6htv.js} +2 -0
  98. package/dist/esm/{withStyled-CrTxIZ0Q.js → withStyled-BBzg5lxJ.js} +1 -1
  99. package/dist/esm/{withTranslation-BtSJmx1J.js → withTranslation-D1H_U5az.js} +2 -2
  100. package/dist/schemas/theme.schema.json +12 -0
  101. package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +1 -1
  102. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +1 -0
  103. package/dist/types/stores/componentStyles.d.ts +4 -0
  104. package/dist/types/utils/annotations.d.ts +2 -0
  105. package/package.json +1 -1
  106. package/dist/bn-template-engine/p-0d8eade3.entry.js +0 -1
  107. package/dist/bn-template-engine/p-7pLJBHT2.js +0 -1
  108. package/dist/components/p-6242qMx1.js +0 -1
  109. package/dist/components/p-9a9XB5Y8.js +0 -1
  110. package/dist/components/p-BXP6aagM.js +0 -1
  111. package/dist/components/p-Bs5V6Ibu.js +0 -1
  112. package/dist/components/p-CZzlLTQc.js +0 -1
@@ -1 +1 @@
1
- import{p as t,H as e,w as s,f as i,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{o as h}from"./p-DdvG1D18.js";import{c as d}from"./p-BXP6aagM.js";import{a as c}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-CcfvGlBq.js";import{w as b}from"./p-BrQCbmG0.js";import{w as x}from"./p-JG4Sx1lE.js";import{w}from"./p-CZzlLTQc.js";import{w as _}from"./p-D32TsLzd.js";import{w as L}from"./p-Bs5V6Ibu.js";import{w as S}from"./p-D65TnLS9.js";import{w as j}from"./p-CU9CdEBF.js";import{r as $,s as R}from"./p-YSRTB0jS.js";import{f as A,c as E,d as N,e as k,p as C,t as F}from"./p-D362XOg2.js";import{s as O}from"./p-DakXa7Dp.js";import{d as z}from"./p-jEqo8YD5.js";const D={rowGroup:0,category:1,subCategory:2},G=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>A(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>E(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>N(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>k(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";y(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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,e)=>this.t(t,e),j(this),b(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),this.componentStyle=x(this),this.ruleSetConfig=L(this),this.t=S(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(){O(this.element,"bn-chart-scatter-renderer");const{mode:t}=m(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 e=this.element,{width:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(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,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=C(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:F(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=C(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=C(e,"measure");if(i||null===s)return null;const{config:a}=F(s);return null!==a&&g(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareIso(){const{data:t,parseError:e}=C(this.iso,null);return e||null===t?null:A(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=C(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:N(e,t).config}prepareLegend(){const{data:t,parseError:e}=C(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=C(this.facet,null);return e||null===t?null:E(t).config}preparePointLevel(){var t,e;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 i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=$(e);null!==t&&"scenario"===t.kind&&s.add(R(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&D[a]>=D[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;D[r]>=D[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}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))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=$(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${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),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return 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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}]}]),B=G,I=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),G);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||z()}}))};export{B as BnChartScatter,I as defineCustomElement}
1
+ import{p as t,H as e,w as s,f as i,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-5LbdDgZ5.js";import{o as h}from"./p-Bmb0YBzz.js";import{c as d}from"./p-CFY-zEXs.js";import{a as c}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-CcfvGlBq.js";import{w as b}from"./p-BrQCbmG0.js";import{w as x}from"./p-NkLVO7n9.js";import{w}from"./p-ClFDt6Bk.js";import{w as _}from"./p-D32TsLzd.js";import{w as L}from"./p-CFF7b9FT.js";import{w as j}from"./p-OR6uR6gy.js";import{w as S}from"./p-CU9CdEBF.js";import{r as R,s as $}from"./p-YSRTB0jS.js";import{f as A,c as N,d as E,e as F,p as k,t as C}from"./p-D362XOg2.js";import{s as O}from"./p-DakXa7Dp.js";import{d as z}from"./p-ChMe_jnA.js";const B={rowGroup:0,category:1,subCategory:2},D=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>A(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>N(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>E(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>F(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";y(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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,e)=>this.t(t,e),S(this),b(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),this.componentStyle=x(this),this.ruleSetConfig=L(this),this.t=j(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(){O(this.element,"bn-chart-scatter-renderer");const{mode:t}=m(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 e=this.element,{width:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(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,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=k(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:C(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=k(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=k(e,"measure");if(i||null===s)return null;const{config:a}=C(s);return null!==a&&g(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareIso(){const{data:t,parseError:e}=k(this.iso,null);return e||null===t?null:A(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=k(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:E(e,t).config}prepareLegend(){const{data:t,parseError:e}=k(this.legend,null);return e||null===t?{show:!0,position:"right"}:F(t).config}prepareFacet(){const{data:t,parseError:e}=k(this.facet,null);return e||null===t?null:N(t).config}preparePointLevel(){var t,e;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 i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=R(e);null!==t&&"scenario"===t.kind&&s.add($(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&B[a]>=B[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;B[r]>=B[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}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))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=R(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${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),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return 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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column}'}},[1,"bn-chart-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}]}]),G=D,I=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),D);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||z()}}))};export{G as BnChartScatter,I as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-9a9XB5Y8.js";const a=o,p=s;export{a as BnChartStructureRenderer,p as defineCustomElement}
1
+ import{B as o,d as p}from"./p-BY1Y1Ipv.js";const s=o,r=p;export{s as BnChartStructureRenderer,r as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{k as c,v as h,a as d,i as p,l as u,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-CZzlLTQc.js";import{w}from"./p-BrQCbmG0.js";import{i as k,w as O,a as A}from"./p-D65TnLS9.js";import{w as _}from"./p-Bp5Xj4-s.js";import{w as N}from"./p-CU9CdEBF.js";import{w as D}from"./p-JG4Sx1lE.js";import{r as x}from"./p-D0v9GMIf.js";import{w as T}from"./p-Bs5V6Ibu.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as W}from"./p-Dsvjkuy3.js";import{r as C,f as U,p as M}from"./p-Xb6Ilq8u.js";import{o as P}from"./p-B6kka9sT.js";import{A as j,e as F,f as z,g as $}from"./p-DguYWLBj.js";import{a as I,O as B}from"./p-BBdzTx8V.js";import{L as E}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-DdvG1D18.js";import{r as J,a as V}from"./p-CckAR27O.js";import{a as X}from"./p-BXP6aagM.js";import{a as q}from"./p-JofGXz75.js";import{s as Y}from"./p-DakXa7Dp.js";import{d as Z}from"./p-9a9XB5Y8.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(k(t)||c(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(k(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===C(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";p(t)?this.errors.remove(i):"invalid"===C(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";p(t)||u(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(k(t))return void this.errors.remove(i);const e=v(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";k(t)||p(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}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",p(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",p(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(p(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(p(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",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.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){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),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.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${U(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${U(e)} percentage points.`}))}},N(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),_(this),this.componentStyle=D(this),this.ruleSetConfig=T(this),this.t=O(this).t,this.resolveInherited=A(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(){Y(this.element,"bn-chart-structure-renderer");const{mode:t}=M(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}=W(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=P(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);this._lastScaledParentHeight=t,s(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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=W(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===C(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===C(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=M(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=W(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,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.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===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...x(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=C(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=C(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return p(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?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===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return p(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||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=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>B[null==t?void 0:t.toUpperCase()])),direction:I[null==s?void 0:s.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=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:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,stackColors:i["bn-chart-structure"].stackColors,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(p(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,e="WARN_stack_dimensions_scenarios";if(i===F.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,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(e)}else this.errors.remove(e);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?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||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"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 p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===F.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,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(i),stackConfig:n,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:o?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 q(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=X(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),u={version:E,tag:this.element.localName,id:V(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:J(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=C(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=C(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=M(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.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 i=this.getFontStyles();return a(r,{key:"02236359d67ec2095ac560152cc6feaa8661834a",style:i},a("div",{key:"5eb4e74f27fb0c4c5ffd286ee266ceb51eae68bf",class:"container"},t.map(this.chartTemplate)))}get element(){return 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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
1
+ import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-5LbdDgZ5.js";import{k as c,v as h,a as d,i as p,l as u,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-ClFDt6Bk.js";import{w}from"./p-BrQCbmG0.js";import{i as k,w as O,a as A}from"./p-OR6uR6gy.js";import{w as _}from"./p-BPvwrhvq.js";import{w as N}from"./p-CU9CdEBF.js";import{w as D}from"./p-NkLVO7n9.js";import{r as x}from"./p-D0v9GMIf.js";import{w as T}from"./p-CFF7b9FT.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as C}from"./p-Dsvjkuy3.js";import{r as W,f as F,p as U}from"./p-Xb6Ilq8u.js";import{o as P}from"./p-B6kka9sT.js";import{A as j,e as M,f as z,g as $}from"./p-DguYWLBj.js";import{a as B,O as I}from"./p-BBdzTx8V.js";import{L as E}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-Bmb0YBzz.js";import{r as V,a as J}from"./p-CckAR27O.js";import{a as Y}from"./p-CFY-zEXs.js";import{a as q}from"./p-JofGXz75.js";import{s as X}from"./p-DakXa7Dp.js";import{d as Z}from"./p-BY1Y1Ipv.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(k(t)||c(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(k(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===W(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";p(t)?this.errors.remove(i):"invalid"===W(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";p(t)||u(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(k(t))return void this.errors.remove(i);const e=v(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";k(t)||p(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}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",p(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",p(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(p(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(p(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",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.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){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),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.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} percentage points.`}))}},N(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),_(this),this.componentStyle=D(this),this.ruleSetConfig=T(this),this.t=O(this).t,this.resolveInherited=A(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(){X(this.element,"bn-chart-structure-renderer");const{mode:t}=U(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}=C(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=P(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=C(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=C(this.element);this._lastScaledParentHeight=t,s(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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=C(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===W(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===W(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=U(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=C(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,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.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===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...x(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=W(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=W(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return p(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?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===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return p(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||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=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>I[null==t?void 0:t.toUpperCase()])),direction:B[null==s?void 0:s.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=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:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,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(p(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,e="WARN_stack_dimensions_scenarios";if(i===M.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,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(e)}else this.errors.remove(e);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?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||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"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 p(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===M.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,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(i),stackConfig:n,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:o?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 q(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=Y(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),u={version:E,tag:this.element.localName,id:J(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:V(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=W(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=W(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=U(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.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 i=this.getFontStyles();return a(r,{key:"edc57c044c2e0f55c3491a96ca102731de2baaab",style:i},a("div",{key:"a653beef4add78d3fef7673003c18a548b58fec1",class:"container"},t.map(this.chartTemplate)))}get element(){return 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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
@@ -1 +1 @@
1
- import{B as o,d as s}from"./p-CiljAoC5.js";const p=o,r=s;export{p as BnChartTimeRenderer,r as defineCustomElement}
1
+ import{B as o,d as p}from"./p-BpyLanO3.js";const s=o,a=p;export{s as BnChartTimeRenderer,a as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as i,w as e,f as s,h as a,d as n,t as r}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{k as h,v as c,a as d,o as p,i as u,f as v,h as m,n as g,p as f,m as b}from"./p-CcfvGlBq.js";import{w as y}from"./p-CZzlLTQc.js";import{w as S}from"./p-BrQCbmG0.js";import{i as x,w,a as A}from"./p-D65TnLS9.js";import{w as M}from"./p-Bp5Xj4-s.js";import{w as _}from"./p-CU9CdEBF.js";import{w as O}from"./p-JG4Sx1lE.js";import{r as T}from"./p-D0v9GMIf.js";import{w as D}from"./p-Bs5V6Ibu.js";import{w as N,r as L}from"./p-D32TsLzd.js";import{g as k}from"./p-Dsvjkuy3.js";import{r as W,f as F,p as P}from"./p-Xb6Ilq8u.js";import{o as j}from"./p-B6kka9sT.js";import{V as R,F as C,v as U}from"./p-Zz3fAPcH.js";import{b as I,e as $,f as B,g as z,h as E}from"./p-DguYWLBj.js";import{D as G}from"./p-ja0FCkHB.js";import{L as V}from"./p-DY5fMUX8.js";import{o as H,m as X}from"./p-DdvG1D18.js";import{r as q,a as J}from"./p-CckAR27O.js";import{a as Y}from"./p-BXP6aagM.js";import{a as Z}from"./p-JofGXz75.js";import{s as Q}from"./p-DakXa7Dp.js";import{d as K}from"./p-CiljAoC5.js";const tt=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(x(t)||h(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(x(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";p(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";u(t)?this.errors.remove(i):"invalid"===W(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";u(t)?this.errors.remove(i):"invalid"===W(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";u(t)||v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' 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)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!m(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.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";u(t)||f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";b(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!m(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!m(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";u(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){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),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.axisLabelsStep=1,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} percentage points.`}))}},_(this),S(this),y(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=N(this),M(this),this.componentStyle=O(this),this.ruleSetConfig=D(this),this.t=w(this).t,this.resolveInherited=A(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.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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=k(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void L(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===W(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===W(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=P(this.scale),h="auto"!==l&&"empty"!==l,c=[];a&&r&&c.push("unit-scaling"),a&&o&&c.push("percentage-scaling"),s&&h&&c.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),L(this.errors,`Chart exceeds available ${d.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(){Q(this.element,"bn-chart-time-renderer");const{mode:t}=P(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}=k(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,r=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,r*(s-1)/n);Math.abs(o-r)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=j(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=k(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=k(this.element);this._lastObservedWidth=t,s(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:e}=k(this.element);e>0&&Math.abs(e-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&s(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=k(this.element),i=this.prepareScenarios(),e=this.prepareSegments();this.canvasWidthSegmented=t.width/(i.length+this.prepareVariances().length||1),this._lastAppliedHeight=t.height;const s=Math.max(1,e.length),a=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-a)/s}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(h(a.value))return this.errors.remove("AUTO_scenarios"),[];const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return u(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.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===(s=a.value)||void 0===s?void 0:s.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 e of this.prepareVariances()){const s=new R(e),a=`${s.type}:${s.delta}`,n=this.scenarioSwitch&&s.isValid?i.get(a):void 0;if(n){n.push(e);continue}const r=[e];t.push(r),s.isValid&&i.set(a,r)}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 u(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new R(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}!this.hidesScenarios()&&e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","date-format-short-year"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...T(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=W(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=W(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=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:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,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 e="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return C.getMaxWidthOfArrayItems([...e,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return u(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),G[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?G.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),G[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return I[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 u(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(u(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,e="WARN_stack_dimensions_scenarios",s="WARN_stack_scenarios_max",a=this.prepareScenarios();return i===$.DIMENSIONS&&a.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${a[0]}" is used, the rest (${a.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e),i===$.SCENARIOS&&a.length>4?this.errors.addOrReplace({id:s,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${a.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(s),{by:i,mode:t.mode||z.ABSOLUTE,order:t.order||B.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?E.LINE:"auto"===i?E.AUTO:E.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=k(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=0===t.length,c=this.hidesScenarios()?U(t):this.prepareScenarios(),d=h&&(null==l?void 0:l.by)===$.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:t.length>0?t:[""],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,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(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:n,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Z(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=H(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,c=this.prepareVariances(),d=Y(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),r,n),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),u={version:V,tag:this.element.localName,id:J(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:X(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:q(this.element),scaling:this.resolveScalingInfo(h),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=W(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=W(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=P(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.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 i=this.getFontStyles();return a(n,{key:"c998214052bad19811135a7c48e669d6ebfdb8cc",style:i},a("div",{key:"8c877fda1575246a4cecc5610aa3b66d6b6f60ce",class:"container"},t.map(this.chartTemplate)))}get element(){return 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}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],axisLabelsStep:[2,"axis-labels-step"],scenarioSwitch:[4,"scenario-switch"],axisTitlePosition:[1,"axis-title-position"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}]),it=tt,et=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),tt);break;case"bn-chart-time-renderer":customElements.get(r(t))||K()}}))};export{it as BnChartTime,et as defineCustomElement}
1
+ import{p as t,H as i,w as e,f as s,h as a,d as n,t as r}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-5LbdDgZ5.js";import{k as h,v as c,a as d,o as p,i as u,f as v,h as m,n as g,p as f,m as b}from"./p-CcfvGlBq.js";import{w as y}from"./p-ClFDt6Bk.js";import{w as S}from"./p-BrQCbmG0.js";import{i as x,w,a as A}from"./p-OR6uR6gy.js";import{w as M}from"./p-BPvwrhvq.js";import{w as O}from"./p-CU9CdEBF.js";import{w as _}from"./p-NkLVO7n9.js";import{r as N}from"./p-D0v9GMIf.js";import{w as L}from"./p-CFF7b9FT.js";import{w as T,r as D}from"./p-D32TsLzd.js";import{g as k}from"./p-Dsvjkuy3.js";import{r as F,f as W,p as P}from"./p-Xb6Ilq8u.js";import{o as R}from"./p-B6kka9sT.js";import{V as C,F as j,v as U}from"./p-Zz3fAPcH.js";import{b as I,e as $,f as B,g as z,h as E}from"./p-DguYWLBj.js";import{D as G}from"./p-ja0FCkHB.js";import{L as V}from"./p-DY5fMUX8.js";import{o as H,m as X}from"./p-Bmb0YBzz.js";import{r as q,a as Y}from"./p-CckAR27O.js";import{a as J}from"./p-CFY-zEXs.js";import{a as Z}from"./p-JofGXz75.js";import{s as Q}from"./p-DakXa7Dp.js";import{d as K}from"./p-BpyLanO3.js";const tt=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(x(t)||h(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(x(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";p(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";u(t)?this.errors.remove(i):"invalid"===F(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";u(t)?this.errors.remove(i):"invalid"===F(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";u(t)||v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:""+t)+"' 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)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!m(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:""+t)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.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";u(t)||f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";b(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!m(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateAxisLabelsStep(t){const i="WARN_axisLabelsStep";!m(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";u(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){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),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.axisLabelsStep=1,this.scenarioSwitch=!1,this.axisTitlePosition="left",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,n,r,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=h/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(r=this.unitScaling)&&void 0!==r?r:"")+"").trim())}, auto-fitted to 1 em ≈ ${W(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*h/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${W(e)} percentage points.`}))}},O(this),S(this),y(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=T(this),M(this),this.componentStyle=_(this),this.ruleSetConfig=L(this),this.t=w(this).t,this.resolveInherited=A(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.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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==n?n:"");Number.isNaN(r)||(e=Math.max(e,r),s=!0)})),s?Math.max(Math.floor(e),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 e=0,s=!1;return null==i||i.forEach((t=>{var i,a,n;const r=parseFloat(null!==(n=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("height"))&&void 0!==n?n:"");Number.isNaN(r)||(e+=r,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=k(this.element),i=this.measureContentWidth(),e=this.measureContentHeight(),s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void D(this.errors,null);const n=this.prepareVariances().some((t=>t.startsWith("dr"))),r="value"===F(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=n&&"value"===F(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=P(this.scale),h="auto"!==l&&"empty"!==l,c=[];a&&r&&c.push("unit-scaling"),a&&o&&c.push("percentage-scaling"),s&&h&&c.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),D(this.errors,`Chart exceeds available ${d.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(){Q(this.element,"bn-chart-time-renderer");const{mode:t}=P(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}=k(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,r=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,r*(s-1)/n);Math.abs(o-r)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=R(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=k(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=k(this.element);this._lastObservedWidth=t,s(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:e}=k(this.element);e>0&&Math.abs(e-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&s(this);const a=t.shift();void 0!==a&&(this._settleTimer=setTimeout(i,a))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=k(this.element),i=this.prepareScenarios(),e=this.prepareSegments();this.canvasWidthSegmented=t.width/(i.length+this.prepareVariances().length||1),this._lastAppliedHeight=t.height;const s=Math.max(1,e.length),a=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-a)/s}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(h(a.value))return this.errors.remove("AUTO_scenarios"),[];const n="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return u(a.value)||n?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(n||a.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===(s=a.value)||void 0===s?void 0:s.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 e of this.prepareVariances()){const s=new C(e),a=`${s.type}:${s.delta}`,n=this.scenarioSwitch&&s.isValid?i.get(a):void 0;if(n){n.push(e);continue}const r=[e];t.push(r),s.isValid&&i.set(a,r)}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 u(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",e=this.prepareScenarios(),s=[];for(const i of t){const t=new C(i);if(t.isValid)for(const a of[t.base,t.delta])e.includes(a)||s.push(`'${i}' needs '${a}'`)}!this.hidesScenarios()&&e.length>0&&s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${s.join(", ")}, which is not in scenarios (${e.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","date-format-short-year"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...N(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=F(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=F(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.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: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=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:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,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 e="left"===this.prepareAxisTitlePosition()?[...this.prepareVariances(),this.chartTitle]:[];return j.getMaxWidthOfArrayItems([...e,...this.prepareScenarios()],t,i)}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareDateInterval(){var t,i,e;const s="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return u(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),G[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?G.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),G[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return I[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 u(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(u(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,e="WARN_stack_dimensions_scenarios",s="WARN_stack_scenarios_max",a=this.prepareScenarios();return i===$.DIMENSIONS&&a.length>1&&!this.scenarioSwitch?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${a[0]}" is used, the rest (${a.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e),i===$.SCENARIOS&&a.length>4?this.errors.addOrReplace({id:s,type:"warning",message:`stack by scenarios: at most four scenarios are stacked, the rest (${a.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`}):this.errors.remove(s),{by:i,mode:t.mode||z.ABSOLUTE,order:t.order||B.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?E.LINE:"auto"===i?E.AUTO:E.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,i){const e=this.prepareI18n(),s=this.prepareStyle(),n=k(this.element).width,r=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),l=this.prepareStackConfig(),h=0===t.length,c=this.hidesScenarios()?U(t):this.prepareScenarios(),d=h&&(null==l?void 0:l.by)===$.DIMENSIONS&&!this.scenarioSwitch?c.slice(0,1):c;return a("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:d,variances:t.length>0?t:[""],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:r,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,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(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:l,lineFullWidth:this.prepareLineFullWidth(),dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},axisLabelsStep:Math.max(1,Math.floor(Number(this.axisLabelsStep)||1)),scenarioSwitch:this.scenarioSwitch,axisTitlePosition:this.prepareAxisTitlePosition(),containerWidth:n,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Z(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,e,s,a;const n=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",r=H(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,c=this.prepareVariances(),d=J(this.element,"bn-chart-time-renderer",this.prepareSegments().map((t=>t.length>0?t.join(","):"base")),r,n),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-time-renderer"),u={version:V,tag:this.element.localName,id:Y(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:X(this.element,r),em:{fontSizePx:h,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:q(this.element),scaling:this.resolveScalingInfo(h),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=F(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const n=F(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)s.percentageMode="fixed",s.percentagePointsPerEm=n.value,s.percentagePxPerPoint=t/n.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=P(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,n;const r=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":r*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(n=i.global)||void 0===n?void 0:n.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 i=this.getFontStyles();return a(n,{key:"c998214052bad19811135a7c48e669d6ebfdb8cc",style:i},a("div",{key:"8c877fda1575246a4cecc5610aa3b66d6b6f60ce",class:"container"},t.map(this.chartTemplate)))}get element(){return 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}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}'}},[1,"bn-chart-time",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[4,"line-full-width"],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],showOverlayAvg:[4,"show-overlay-avg"],showOverlayMedian:[4,"show-overlay-median"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],axisLabelsStep:[2,"axis-labels-step"],scenarioSwitch:[4,"scenario-switch"],axisTitlePosition:[1,"axis-title-position"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{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}],axisLabelsStep:[{validateAxisLabelsStep:0}],axisTitlePosition:[{validateAxisTitlePosition:0}]}]),it=tt,et=function(){"undefined"!=typeof customElements&&["bn-chart-time","bn-chart-time-renderer"].forEach((t=>{switch(t){case"bn-chart-time":customElements.get(r(t))||customElements.define(r(t),tt);break;case"bn-chart-time-renderer":customElements.get(r(t))||K()}}))};export{it as BnChartTime,et as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as s,h as e,d as o,t as n}from"./p-BnmylmXF.js";import{w as r}from"./p-BP2sJ8k9.js";import{g as i,u as m}from"./p-6242qMx1.js";import{w as p}from"./p-BrQCbmG0.js";import{w as y}from"./p-D32TsLzd.js";const a=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.name="_default",p(this),this.errors=y(this),r(this,(t=>{this.stores||(this.stores=i(this.element));try{const s=JSON.parse(t);this.stores.componentStyles.set(this.name,s),this.errors.remove("ERR_body");const e=m(s);e.length>0?this.errors.addOrReplace({id:"ERR_keys",type:"error",message:"Unknown style keys, they are ignored: "+e.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 e(o,{key:"443fd52bc75e267b8699e29f754a15130f444315"})}get element(){return this}static get style(){return"bn-component-style{display:none}"}},[0,"bn-component-style",{name:[1]}]),c=a,h=function(){"undefined"!=typeof customElements&&["bn-component-style"].forEach((t=>{"bn-component-style"===t&&(customElements.get(n(t))||customElements.define(n(t),a))}))};export{c as BnComponentStyle,h as defineCustomElement}
1
+ import{p as t,H as s,h as e,d as o,t as n}from"./p-BnmylmXF.js";import{w as r}from"./p-BP2sJ8k9.js";import{g as i,u as m}from"./p-5LbdDgZ5.js";import{w as p}from"./p-BrQCbmG0.js";import{w as y}from"./p-D32TsLzd.js";const a=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.name="_default",p(this),this.errors=y(this),r(this,(t=>{this.stores||(this.stores=i(this.element));try{const s=JSON.parse(t);this.stores.componentStyles.set(this.name,s),this.errors.remove("ERR_body");const e=m(s);e.length>0?this.errors.addOrReplace({id:"ERR_keys",type:"error",message:"Unknown style keys, they are ignored: "+e.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 e(o,{key:"443fd52bc75e267b8699e29f754a15130f444315"})}get element(){return this}static get style(){return"bn-component-style{display:none}"}},[0,"bn-component-style",{name:[1]}]),c=a,h=function(){"undefined"!=typeof customElements&&["bn-component-style"].forEach((t=>{"bn-component-style"===t&&(customElements.get(n(t))||customElements.define(n(t),a))}))};export{c as BnComponentStyle,h as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as e,e as o,f as n,h as i,d as a,t as r}from"./p-BnmylmXF.js";import{F as s}from"./p-Zz3fAPcH.js";import{S as c,e as l}from"./p-6242qMx1.js";import{L as p}from"./p-DY5fMUX8.js";import{m as u,t as h}from"./p-DdvG1D18.js";import{r as d,a as m,b,c as f}from"./p-CckAR27O.js";import{b as g}from"./p-VtNvNyZK.js";import{w as v}from"./p-BrQCbmG0.js";import{m as y}from"./p-JG4Sx1lE.js";import{w}from"./p-D32TsLzd.js";import{b as x}from"./p-DM7fwmH4.js";function S(t){if("function"==typeof getComputedStyle){const e=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(e)&&e>0)return e}return c.global.fontSizePx}function j(t,e){var o;return{version:p,tag:t.localName,id:m(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:u(t,e),em:{fontSizePx:S(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:d(t)}}const L=new Map,P={"thin-space":" ",space:" ",none:""};function D(t){var e;let o="";for(const t of L.values())o=t.separator()||o;const n=o?null!==(e=P[o])&&void 0!==e?e:o:null;if(n!==s.groupSeparator){s.groupSeparator=n;for(const[e,o]of L)e!==t&&o.redraw()}}const N=["format","orientation","page-format","page-orientation","render-orientation","page-number"],k=(t,e,o)=>{const n=t[e];return"string"==typeof n?n:e in t?null:t.getAttribute(o)},C=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.bnNotationChange=o(this,"bnNotationChange",7),this.groupSeparator="",this.wasConnected=!1,this.assignedPageNumbers=new WeakMap,this.notationSubscriptions=[],v(this),this.errors=w(this)}watchGroupSeparator(){D()}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=l(this.element),this.locale&&(this.stores.context.state.locale=this.locale),L.set(this,{separator:()=>{var t;return null!==(t=this.groupSeparator)&&void 0!==t?t:""},redraw:()=>{const t=this.stores.context.state,e=t.locale;t.locale="",t.locale=e}}),D(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:N})}disconnectedCallback(){var t,e;L.delete(this),D(),this.notationSubscriptions.forEach((t=>t())),this.notationSubscriptions=[],null===(t=this.pageObserver)||void 0===t||t.disconnect(),null===(e=this.pageSizeStyle)||void 0===e||e.remove(),this.pageSizeStyle=void 0}syncPages(){const t=Array.from(this.element.querySelectorAll("bn-page, bn-layout-page"));t.forEach(((t,e)=>{const o="bn-layout-page"===t.localName?t:t.querySelector("bn-footer");if(!o)return;const n=k(o,"pageNumber","page-number");if(null!==n&&n!==this.assignedPageNumbers.get(o))return;const i=""+(e+1);this.assignedPageNumbers.set(o,i),n!==i&&o.setAttribute("page-number",i)}));const e=this.element.getAttribute("render-orientation");void 0!==this.lastRenderOrientation&&this.lastRenderOrientation!==e&&t.filter((t=>"bn-layout-page"===t.localName)).forEach((t=>n(t))),this.lastRenderOrientation=e,this.writePageSize(t[0],e)}writePageSize(t,e){var o;if(!t||document.querySelector("bn-context")!==this.element)return null===(o=this.pageSizeStyle)||void 0===o||o.remove(),void(this.pageSizeStyle=void 0);const n="bn-layout-page"===t.localName?x(k(t,"pageFormat","page-format"),k(t,"pageOrientation","page-orientation"),e):x(k(t,"format","format"),k(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!==n&&(this.pageSizeStyle.textContent=n)}async getLayoutState(t){var e,o;const n=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=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(i.map((t=>{var e,o,n;return null!==(n=null===(o=(e=t).componentOnReady)||void 0===o?void 0:o.call(e))&&void 0!==n?n:Promise.resolve()})));const a=this.element.getBoundingClientRect(),r={x:a.left,y:a.top},s=await Promise.all(i.map((async t=>{const e=t.getBoundingClientRect(),o={context:r,component:{x:e.left,y:e.top}};try{const e=t;return"function"==typeof e.getLayoutState?await e.getLayoutState({detail:n}):j(t,o)}catch(e){let n;try{n=j(t,o)}catch(e){const o={x:0,y:0,width:0,height:0};n={version:p,tag:t.localName,id:t.localName,rect:{context:Object.assign({},o),component:Object.assign({},o)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return n.error=(e instanceof Error?e.message:e)+"",n}}))),c=b(i.map((t=>({tag:t.localName,explicitId:f(t)}))));return s.forEach(((t,e)=>{t.id=c[e]})),{version:p,generatedAt:(new Date).toISOString(),detail:n,context:{viewport:h(a),locale:null===(o=this.stores)||void 0===o?void 0:o.context.state.locale},components:s}}async getNotation(t){const e=Array.from(this.element.querySelectorAll("bn-component-style, bn-scaling-group"));return await Promise.all(e.map((t=>{var e,o;return null!==(o=null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t))&&void 0!==o?o:Promise.resolve()}))),g(y(this.stores.componentStyles.state,t),this.stores.scalingGroups.state)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(a,{key:"835bf8fe0cf78440c000ce996495c5c5c0cbbd07"},i("slot",{key:"395cbc8fdbb4f6e765d36a93a7547272e5ec7def"}))}get element(){return this}static get watchers(){return{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}}static get style(){return":host{display:block}"}},[257,"bn-context",{locale:[1],i18nNamespace:[513,"i18n-namespace"],renderOrientation:[513,"render-orientation"],groupSeparator:[1,"group-separator"],getLayoutState:[64],getNotation:[64]},void 0,{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}]),F=C,z=function(){"undefined"!=typeof customElements&&["bn-context"].forEach((t=>{"bn-context"===t&&(customElements.get(r(t))||customElements.define(r(t),C))}))};export{F as BnContext,z as defineCustomElement}
1
+ import{p as t,H as e,e as o,f as n,h as i,d as a,t as r}from"./p-BnmylmXF.js";import{F as s}from"./p-Zz3fAPcH.js";import{S as c,e as l}from"./p-5LbdDgZ5.js";import{L as p}from"./p-DY5fMUX8.js";import{m as u,t as h}from"./p-Bmb0YBzz.js";import{r as m,a as d,b,c as f}from"./p-CckAR27O.js";import{b as g}from"./p-VtNvNyZK.js";import{w as v}from"./p-BrQCbmG0.js";import{m as y}from"./p-NkLVO7n9.js";import{w}from"./p-D32TsLzd.js";import{b as S}from"./p-DM7fwmH4.js";function x(t){if("function"==typeof getComputedStyle){const e=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(e)&&e>0)return e}return c.global.fontSizePx}function j(t,e){var o;return{version:p,tag:t.localName,id:d(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:u(t,e),em:{fontSizePx:x(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:m(t)}}const L=new Map,P={"thin-space":" ",space:" ",none:""};function N(t){var e;let o="";for(const t of L.values())o=t.separator()||o;const n=o?null!==(e=P[o])&&void 0!==e?e:o:null;if(n!==s.groupSeparator){s.groupSeparator=n;for(const[e,o]of L)e!==t&&o.redraw()}}const k=["format","orientation","page-format","page-orientation","render-orientation","page-number"],z=(t,e,o)=>{const n=t[e];return"string"==typeof n?n:e in t?null:t.getAttribute(o)},D=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.bnNotationChange=o(this,"bnNotationChange",7),this.groupSeparator="",this.wasConnected=!1,this.assignedPageNumbers=new WeakMap,this.notationSubscriptions=[],v(this),this.errors=w(this)}watchGroupSeparator(){N()}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=l(this.element),this.locale&&(this.stores.context.state.locale=this.locale),L.set(this,{separator:()=>{var t;return null!==(t=this.groupSeparator)&&void 0!==t?t:""},redraw:()=>{const t=this.stores.context.state,e=t.locale;t.locale="",t.locale=e}}),N(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:k})}disconnectedCallback(){var t,e;L.delete(this),N(),this.notationSubscriptions.forEach((t=>t())),this.notationSubscriptions=[],null===(t=this.pageObserver)||void 0===t||t.disconnect(),null===(e=this.pageSizeStyle)||void 0===e||e.remove(),this.pageSizeStyle=void 0}syncPages(){const t=Array.from(this.element.querySelectorAll("bn-page, bn-layout-page"));t.forEach(((t,e)=>{const o="bn-layout-page"===t.localName?t:t.querySelector("bn-footer");if(!o)return;const n=z(o,"pageNumber","page-number");if(null!==n&&n!==this.assignedPageNumbers.get(o))return;const i=""+(e+1);this.assignedPageNumbers.set(o,i),n!==i&&o.setAttribute("page-number",i)}));const e=this.element.getAttribute("render-orientation");void 0!==this.lastRenderOrientation&&this.lastRenderOrientation!==e&&t.filter((t=>"bn-layout-page"===t.localName)).forEach((t=>n(t))),this.lastRenderOrientation=e,this.writePageSize(t[0],e)}writePageSize(t,e){var o;if(!t||document.querySelector("bn-context")!==this.element)return null===(o=this.pageSizeStyle)||void 0===o||o.remove(),void(this.pageSizeStyle=void 0);const n="bn-layout-page"===t.localName?S(z(t,"pageFormat","page-format"),z(t,"pageOrientation","page-orientation"),e):S(z(t,"format","format"),z(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!==n&&(this.pageSizeStyle.textContent=n)}async getLayoutState(t){var e,o;const n=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=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(i.map((t=>{var e,o,n;return null!==(n=null===(o=(e=t).componentOnReady)||void 0===o?void 0:o.call(e))&&void 0!==n?n:Promise.resolve()})));const a=this.element.getBoundingClientRect(),r={x:a.left,y:a.top},s=await Promise.all(i.map((async t=>{const e=t.getBoundingClientRect(),o={context:r,component:{x:e.left,y:e.top}};try{const e=t;return"function"==typeof e.getLayoutState?await e.getLayoutState({detail:n}):j(t,o)}catch(e){let n;try{n=j(t,o)}catch(e){const o={x:0,y:0,width:0,height:0};n={version:p,tag:t.localName,id:t.localName,rect:{context:Object.assign({},o),component:Object.assign({},o)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return n.error=(e instanceof Error?e.message:e)+"",n}}))),c=b(i.map((t=>({tag:t.localName,explicitId:f(t)}))));return s.forEach(((t,e)=>{t.id=c[e]})),{version:p,generatedAt:(new Date).toISOString(),detail:n,context:{viewport:h(a),locale:null===(o=this.stores)||void 0===o?void 0:o.context.state.locale},components:s}}async getNotation(t){const e=Array.from(this.element.querySelectorAll("bn-component-style, bn-scaling-group"));return await Promise.all(e.map((t=>{var e,o;return null!==(o=null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t))&&void 0!==o?o:Promise.resolve()}))),g(y(this.stores.componentStyles.state,t),this.stores.scalingGroups.state)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(a,{key:"835bf8fe0cf78440c000ce996495c5c5c0cbbd07"},i("slot",{key:"395cbc8fdbb4f6e765d36a93a7547272e5ec7def"}))}get element(){return this}static get watchers(){return{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}}static get style(){return":host{display:block}"}},[257,"bn-context",{locale:[1],i18nNamespace:[513,"i18n-namespace"],renderOrientation:[513,"render-orientation"],groupSeparator:[1,"group-separator"],getLayoutState:[64],getNotation:[64]},void 0,{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}]),C=D,F=function(){"undefined"!=typeof customElements&&["bn-context"].forEach((t=>{"bn-context"===t&&(customElements.get(r(t))||customElements.define(r(t),D))}))};export{C as BnContext,F as defineCustomElement}
@@ -1 +1 @@
1
- import{c as t,p as s,H as i,h,d as e,t as r}from"./p-BnmylmXF.js";import{g as n,c as l,h as a}from"./p-6242qMx1.js";import{r as o,w as c}from"./p-BrQCbmG0.js";import{w as u}from"./p-BP2sJ8k9.js";import{w as d}from"./p-D32TsLzd.js";import{d as f,c as m}from"./p-CYwd_ZNM.js";import{e as p}from"./p-ClruFZD_.js";const y=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],v=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function R(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function g(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const E=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),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 s=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"),s&&this.reload())},this.holdStatus=c(this),this.errors=d(this),((s,i)=>{let h,e=[],r=[];const a=t=>{let s;try{s=h.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{e.forEach((t=>t())),e=[],r.forEach((t=>{t&&(e.push(h.db.subscribe(t,(()=>a(t)))),a(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);h=n(i),r=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),o(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),e.forEach((t=>t())),e=[],l(t(s)),o(f,s)}})(this,(()=>{this.executeQuery()})),u(this,(t=>this.sync(t)))}sync(t){if(this.stores=n(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 s,i;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src"),!this.raw&&this.static&&""!==t.trim())try{const h=f(t);s=h.hash,i=h.json}catch(t){return this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: "+p(t)}),void(this.lastBodyHash=null)}else s=m(t),i=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.errors.remove("ERR_body"),this.query=i,this.executeQuery())}executeQuery(){var t,s;if(this.stores||(this.stores=n(this.element)),this.query||this.errors.remove("ERR_sql"),!this.name)return;if(!(this.query||this.static&&null===this.currentUrl))return;const i=this.stores.db.db;let h;if(this.static){try{h=""===this.query.trim()?[]:null!==(t=JSON.parse(this.query))&&void 0!==t?t:[],Array.isArray(h)?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: "+p(t)}),h=[]}i.tables[this.name]={data:Array.isArray(h)?h:[]},this.registered=i.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_sql")}else{if(this.lastViewQuery!==this.query){try{i.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=i.tables[this.name]&&delete i.tables[this.name],i.views&&null!=i.views[this.name]&&delete i.views[this.name];try{if(a(this.query))throw Error("double backticks are not allowed.");i.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.registered=i.tables[this.name],i.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)}),i.resetSqlCache(),this.lastViewQuery=null,h=[],void this.publish(h)}}else null===(s=i.tables[this.name])||void 0===s||delete s.select;try{h=i.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(h)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.publishedMeta=function(t){const s={};for(const t of v)s[t]=new Set;const i={};for(const t of y)i[t]={hasData:!1,min:null,max:null};const h=new Set;let e=null,r=null;const n=Array.isArray(t)?t:[];for(let t=0;t<n.length;t++){const l=n[t];if(null==l)continue;for(const t of v){const i=l[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of y){const s=l[t];if(R(s)){const h=i[t];h.hasData=!0,(null===h.min||s<h.min)&&(h.min=s),(null===h.max||s>h.max)&&(h.max=s)}}const a=l.date;if(null!=a&&""!==a){const t=a+"";h.add(t),(null===e||t<e)&&(e=t),(null===r||t>r)&&(r=t)}}const l=y.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),a=l.filter((t=>t.hasData)).map((t=>t.key)),o=g(s.rowGroup),c=g(s.category),u=g(s.subCategory),d=g(s.columnGroup),f=g(s.columnSubGroup),m={min:e,max:r,hasData:h.size>0,distinctCount:h.size};let p="category";return u.hasData?p="subCategory":c.hasData?p="category":o.hasData&&(p="rowGroup"),{rowCount:n.length,scenarios:l,availableScenarios:a,rowGroup:o,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:m,suggestedLevel:p,suggestedOrder:p,suggestedDateInterval:m.hasData?"auto":null,calculatedAt:Date.now()}}(t),this.stores.datasetsMeta.set(this.name,this.publishedMeta)):this.stores.db.notify(this.name)}nameUpdated(t,s){var i;this.unregister(s),this.name&&this.element.isConnected&&this.sync(null!==(i=this.element.textContent)&&void 0!==i?i:"")}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 s,i,h;const e=null===(i=null===(s=this.stores)||void 0===s?void 0:s.db)||void 0===i?void 0:i.db;e&&null!==this.lastViewQuery&&e.resetSqlCache(),null===(h=this.releaseName)||void 0===h||h.call(this),this.releaseName=void 0;const r=null!=(null==e?void 0:e.tables[t])&&e.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,e&&t&&!r){try{e.exec(`DROP VIEW \`${t}\``)}catch(t){}null!=e.tables[t]&&delete e.tables[t],e.views&&null!=e.views[t]&&delete e.views[t],this.stores.datasetsMeta.set(t,null),this.stores.db.notify(t)}}async fetchAndStore(t){var s,i;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=n(this.element));try{const s=await fetch(t,{signal:this.abortController.signal});if(!s.ok)throw Error("HTTP "+s.status);const h=null!==(i=await s.json())&&void 0!==i?i:[];if(!Array.isArray(h))throw Error("not a JSON array.");const e=this.stores.db.db;e.tables[this.name]={data:h},this.registered=e.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_src"),this.publish(h)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:"src: "+p(t)});const s=this.stores.db.db;s.tables[this.name]={data:[]},this.registered=s.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 h(e,{key:"9a491c13d9ad8fba5da3c30f502a027a5ae1c606"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],refreshInterval:[2,"refresh-interval"],src:[1]},void 0,{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}]),b=E,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(r(t))||customElements.define(r(t),E))}))};export{b as BnDataset,w as defineCustomElement}
1
+ import{c as t,p as s,H as i,h,d as e,t as r}from"./p-BnmylmXF.js";import{g as n,c as l,h as a}from"./p-5LbdDgZ5.js";import{r as o,w as c}from"./p-BrQCbmG0.js";import{w as u}from"./p-BP2sJ8k9.js";import{w as d}from"./p-D32TsLzd.js";import{d as f,c as m}from"./p-CYwd_ZNM.js";import{e as p}from"./p-ClruFZD_.js";const y=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],v=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function R(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function g(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const E=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),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 s=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"),s&&this.reload())},this.holdStatus=c(this),this.errors=d(this),((s,i)=>{let h,e=[],r=[];const a=t=>{let s;try{s=h.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{e.forEach((t=>t())),e=[],r.forEach((t=>{t&&(e.push(h.db.subscribe(t,(()=>a(t)))),a(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);h=n(i),r=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),o(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),e.forEach((t=>t())),e=[],l(t(s)),o(f,s)}})(this,(()=>{this.executeQuery()})),u(this,(t=>this.sync(t)))}sync(t){if(this.stores=n(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 s,i;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src"),!this.raw&&this.static&&""!==t.trim())try{const h=f(t);s=h.hash,i=h.json}catch(t){return this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: "+p(t)}),void(this.lastBodyHash=null)}else s=m(t),i=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.errors.remove("ERR_body"),this.query=i,this.executeQuery())}executeQuery(){var t,s;if(this.stores||(this.stores=n(this.element)),this.query||this.errors.remove("ERR_sql"),!this.name)return;if(!(this.query||this.static&&null===this.currentUrl))return;const i=this.stores.db.db;let h;if(this.static){try{h=""===this.query.trim()?[]:null!==(t=JSON.parse(this.query))&&void 0!==t?t:[],Array.isArray(h)?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: "+p(t)}),h=[]}i.tables[this.name]={data:Array.isArray(h)?h:[]},this.registered=i.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_sql")}else{if(this.lastViewQuery!==this.query){try{i.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=i.tables[this.name]&&delete i.tables[this.name],i.views&&null!=i.views[this.name]&&delete i.views[this.name];try{if(a(this.query))throw Error("double backticks are not allowed.");i.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.registered=i.tables[this.name],i.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)}),i.resetSqlCache(),this.lastViewQuery=null,h=[],void this.publish(h)}}else null===(s=i.tables[this.name])||void 0===s||delete s.select;try{h=i.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(h)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.publishedMeta=function(t){const s={};for(const t of v)s[t]=new Set;const i={};for(const t of y)i[t]={hasData:!1,min:null,max:null};const h=new Set;let e=null,r=null;const n=Array.isArray(t)?t:[];for(let t=0;t<n.length;t++){const l=n[t];if(null==l)continue;for(const t of v){const i=l[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of y){const s=l[t];if(R(s)){const h=i[t];h.hasData=!0,(null===h.min||s<h.min)&&(h.min=s),(null===h.max||s>h.max)&&(h.max=s)}}const a=l.date;if(null!=a&&""!==a){const t=a+"";h.add(t),(null===e||t<e)&&(e=t),(null===r||t>r)&&(r=t)}}const l=y.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),a=l.filter((t=>t.hasData)).map((t=>t.key)),o=g(s.rowGroup),c=g(s.category),u=g(s.subCategory),d=g(s.columnGroup),f=g(s.columnSubGroup),m={min:e,max:r,hasData:h.size>0,distinctCount:h.size};let p="category";return u.hasData?p="subCategory":c.hasData?p="category":o.hasData&&(p="rowGroup"),{rowCount:n.length,scenarios:l,availableScenarios:a,rowGroup:o,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:m,suggestedLevel:p,suggestedOrder:p,suggestedDateInterval:m.hasData?"auto":null,calculatedAt:Date.now()}}(t),this.stores.datasetsMeta.set(this.name,this.publishedMeta)):this.stores.db.notify(this.name)}nameUpdated(t,s){var i;this.unregister(s),this.name&&this.element.isConnected&&this.sync(null!==(i=this.element.textContent)&&void 0!==i?i:"")}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 s,i,h;const e=null===(i=null===(s=this.stores)||void 0===s?void 0:s.db)||void 0===i?void 0:i.db;e&&null!==this.lastViewQuery&&e.resetSqlCache(),null===(h=this.releaseName)||void 0===h||h.call(this),this.releaseName=void 0;const r=null!=(null==e?void 0:e.tables[t])&&e.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,e&&t&&!r){try{e.exec(`DROP VIEW \`${t}\``)}catch(t){}null!=e.tables[t]&&delete e.tables[t],e.views&&null!=e.views[t]&&delete e.views[t],this.stores.datasetsMeta.set(t,null),this.stores.db.notify(t)}}async fetchAndStore(t){var s,i;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=n(this.element));try{const s=await fetch(t,{signal:this.abortController.signal});if(!s.ok)throw Error("HTTP "+s.status);const h=null!==(i=await s.json())&&void 0!==i?i:[];if(!Array.isArray(h))throw Error("not a JSON array.");const e=this.stores.db.db;e.tables[this.name]={data:h},this.registered=e.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_src"),this.publish(h)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:"src: "+p(t)});const s=this.stores.db.db;s.tables[this.name]={data:[]},this.registered=s.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 h(e,{key:"9a491c13d9ad8fba5da3c30f502a027a5ae1c606"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],refreshInterval:[2,"refresh-interval"],src:[1]},void 0,{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}]),b=E,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(r(t))||customElements.define(r(t),E))}))};export{b as BnDataset,w as defineCustomElement}
@@ -1 +1 @@
1
- import{p as t,H as s,h as i,d as h,t as r}from"./p-BnmylmXF.js";import{w as e}from"./p-BP2sJ8k9.js";import{g as n,c as a}from"./p-6242qMx1.js";import{w as l}from"./p-BrQCbmG0.js";import{w as o}from"./p-D32TsLzd.js";import{c as d,d as c}from"./p-CYwd_ZNM.js";import{e as u}from"./p-ClruFZD_.js";const m=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),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 s=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"),s&&this.reload())},this.holdStatus=l(this),this.errors=o(this),e(this,(t=>this.sync(t)))}sync(t){var s;if(this.stores=n(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 i,h;if(this.raw||""===t.trim())i=d(t),h=t;else{const s=c(t);i=s.hash,h=s.json}if(i===this.lastHash)return;this.lastHash=i;const r=""===h.trim()?[]:null!==(s=JSON.parse(h))&&void 0!==s?s:[];Array.isArray(r)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."}),this.publish(r)}catch(t){this.lastHash=null,this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: "+u(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 s=this.stores.db.db;s.tables[this.name]={data:Array.isArray(t)?t:[]},this.registered=s.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,s){var i;this.unregister(s),this.name&&this.element.isConnected&&this.sync(null!==(i=this.element.textContent)&&void 0!==i?i:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name),a(this.element)}unregister(t){var s,i,h;null===(s=this.releaseName)||void 0===s||s.call(this),this.releaseName=void 0,this.lastHash=null,this.currentUrl=null;const r=null===(h=null===(i=this.stores)||void 0===i?void 0:i.db)||void 0===h?void 0:h.db,e=null!=(null==r?void 0:r.tables[t])&&r.tables[t]!==this.registered;this.registered=void 0,r&&t&&!e&&(null!=r.tables[t]&&delete r.tables[t],r.views&&null!=r.views[t]&&delete r.views[t],this.stores.db.notify(t))}async fetchAndStore(t){var s,i;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=n(this.element));try{const s=await fetch(t,{signal:this.abortController.signal});if(!s.ok)throw Error("HTTP "+s.status);const h=null!==(i=await s.json())&&void 0!==i?i:[];if(!Array.isArray(h))throw Error("not a JSON array.");this.errors.remove("ERR_src"),this.publish(h)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:"src: "+u(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(h,{key:"323018b2b642f9905874f94010c75b19bebde639"})}get element(){return this}static get watchers(){return{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],refreshInterval:[2,"refresh-interval"],src:[1]},void 0,{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}]),v=m,p=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(r(t))||customElements.define(r(t),m))}))};export{v as BnDatasource,p as defineCustomElement}
1
+ import{p as t,H as s,h as i,d as h,t as r}from"./p-BnmylmXF.js";import{w as e}from"./p-BP2sJ8k9.js";import{g as n,c as a}from"./p-5LbdDgZ5.js";import{w as l}from"./p-BrQCbmG0.js";import{w as o}from"./p-D32TsLzd.js";import{c as d,d as c}from"./p-CYwd_ZNM.js";import{e as u}from"./p-ClruFZD_.js";const m=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),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 s=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"),s&&this.reload())},this.holdStatus=l(this),this.errors=o(this),e(this,(t=>this.sync(t)))}sync(t){var s;if(this.stores=n(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 i,h;if(this.raw||""===t.trim())i=d(t),h=t;else{const s=c(t);i=s.hash,h=s.json}if(i===this.lastHash)return;this.lastHash=i;const r=""===h.trim()?[]:null!==(s=JSON.parse(h))&&void 0!==s?s:[];Array.isArray(r)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."}),this.publish(r)}catch(t){this.lastHash=null,this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: "+u(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 s=this.stores.db.db;s.tables[this.name]={data:Array.isArray(t)?t:[]},this.registered=s.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,s){var i;this.unregister(s),this.name&&this.element.isConnected&&this.sync(null!==(i=this.element.textContent)&&void 0!==i?i:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name),a(this.element)}unregister(t){var s,i,h;null===(s=this.releaseName)||void 0===s||s.call(this),this.releaseName=void 0,this.lastHash=null,this.currentUrl=null;const r=null===(h=null===(i=this.stores)||void 0===i?void 0:i.db)||void 0===h?void 0:h.db,e=null!=(null==r?void 0:r.tables[t])&&r.tables[t]!==this.registered;this.registered=void 0,r&&t&&!e&&(null!=r.tables[t]&&delete r.tables[t],r.views&&null!=r.views[t]&&delete r.views[t],this.stores.db.notify(t))}async fetchAndStore(t){var s,i;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=n(this.element));try{const s=await fetch(t,{signal:this.abortController.signal});if(!s.ok)throw Error("HTTP "+s.status);const h=null!==(i=await s.json())&&void 0!==i?i:[];if(!Array.isArray(h))throw Error("not a JSON array.");this.errors.remove("ERR_src"),this.publish(h)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:"src: "+u(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(h,{key:"323018b2b642f9905874f94010c75b19bebde639"})}get element(){return this}static get watchers(){return{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],refreshInterval:[2,"refresh-interval"],src:[1]},void 0,{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}]),v=m,p=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(r(t))||customElements.define(r(t),m))}))};export{v as BnDatasource,p as defineCustomElement}
@@ -1 +1 @@
1
- import{F as s,d as o}from"./p-2t-lysdb.js";const t=s,p=o;export{t as BnFooter,p as defineCustomElement}
1
+ import{F as o,d as s}from"./p-YuXVqXS_.js";const p=o,r=s;export{p as BnFooter,r as defineCustomElement}