@bino-bi/bn-template-engine 1.0.0-next.48 → 1.0.0-next.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-b3f5eba0.entry.js → p-2de524d0.entry.js} +1 -1
- package/dist/bn-template-engine/{p-a6017fce.entry.js → p-510d2ee6.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6ab684a9.entry.js → p-8fc90dc8.entry.js} +1 -1
- package/dist/bn-template-engine/p-BFl7OwcC.js +1 -0
- package/dist/bn-template-engine/{p-3ktFZb1x.js → p-Bxa4pX1M.js} +1 -1
- package/dist/bn-template-engine/p-c1d679af.entry.js +1 -0
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +628 -108
- package/dist/cjs/bn-grid.cjs.entry.js +1 -1
- package/dist/cjs/bn-image.cjs.entry.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +2 -2
- package/dist/cjs/{withStyled-DHKHBdRb.js → withStyled-pkdctrK9.js} +18 -1
- package/dist/cjs/{withTranslation-CLwC9a8V.js → withTranslation-BIzTNYZM.js} +1 -1
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.css +19 -0
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +65 -8
- package/dist/collection/components/bn-annotation-layer/utils/marks.js +85 -5
- package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +7 -1
- package/dist/collection/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +20 -6
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +55 -23
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +329 -53
- package/dist/collection/components/bn-chart-time/utils/elements/Column.js +4 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +2 -1
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +53 -11
- package/dist/collection/utils/annotations.js +1 -1
- package/dist/collection/utils/constants.js +2 -0
- package/dist/collection/utils/layoutState/svgChartElements.js +10 -0
- package/dist/collection/utils/validate.js +16 -1
- package/dist/components/bn-annotation-layer.js +1 -1
- package/dist/components/bn-annotation-list.js +1 -1
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-page.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title-renderer.js +1 -1
- package/dist/components/bn-title.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/{p-CLjuZoiT.js → p-B11cXOLy.js} +1 -1
- package/dist/components/p-BBdzTx8V.js +1 -0
- package/dist/components/{p-B1_wkOLx.js → p-BVNOmHh4.js} +1 -1
- package/dist/components/p-BXP6aagM.js +1 -0
- package/dist/components/{p-CG-iY7pQ.js → p-Blre9f28.js} +1 -1
- package/dist/components/p-CHJ6WE0l.js +1 -0
- package/dist/components/{p-Do4GqlMV.js → p-CHhxQoF9.js} +1 -1
- package/dist/components/{p-C-3TOa6K.js → p-CJ0-xdfZ.js} +1 -1
- package/dist/components/{p-BFoRIqDi.js → p-CO6bgquz.js} +1 -1
- package/dist/components/{p-CytMTBFu.js → p-CSJCkHEL.js} +1 -1
- package/dist/components/p-CVfmhtEW.js +1 -0
- package/dist/components/{p-Zuxd3z0q.js → p-Cc0gaLwp.js} +1 -1
- package/dist/components/p-CuUfiEu0.js +1 -0
- package/dist/components/{p-DUZCLRVu.js → p-D362XOg2.js} +1 -1
- package/dist/components/p-DBj1Yd3M.js +1 -0
- package/dist/components/{p-BjgkgCAQ.js → p-DHX92KDP.js} +1 -1
- package/dist/components/p-DHloMyxV.js +1 -0
- package/dist/components/{p-Uc0zvXcQ.js → p-Dd1QOWDV.js} +1 -1
- package/dist/components/p-DguYWLBj.js +1 -0
- package/dist/components/p-Do-IGHJk.js +1 -0
- package/dist/components/{p-DDo-fu3v.js → p-DsC0ew4j.js} +1 -1
- package/dist/components/p-HVN8BNWN.js +1 -0
- package/dist/components/{p-Dyzb4ika.js → p-YSRTB0jS.js} +1 -1
- package/dist/components/{p-CrZ_O3DT.js → p-k7heRDPP.js} +1 -1
- package/dist/components/{p-dO0utE8m.js → p-keKnrAVS.js} +1 -1
- package/dist/components/p-x0W2_FAX.js +1 -0
- package/dist/components/p-y12CmIFS.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +628 -108
- package/dist/esm/bn-grid.entry.js +1 -1
- package/dist/esm/bn-image.entry.js +1 -1
- package/dist/esm/bn-text.entry.js +2 -2
- package/dist/esm/{withStyled-CTZFjg4L.js → withStyled-B62R20Zx.js} +18 -1
- package/dist/esm/{withTranslation-BESW5BNq.js → withTranslation-BEseMLQ6.js} +1 -1
- package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +48 -0
- package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +4 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +29 -6
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +51 -2
- package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +5 -1
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +6 -0
- package/dist/types/components.d.ts +6 -6
- package/dist/types/utils/annotations.d.ts +11 -1
- package/dist/types/utils/constants.d.ts +3 -1
- package/dist/types/utils/layoutState/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-203e7d6a.entry.js +0 -1
- package/dist/bn-template-engine/p-DXtYQE4s.js +0 -1
- package/dist/components/p-6gET6YXc.js +0 -1
- package/dist/components/p-BFWvVe7v.js +0 -1
- package/dist/components/p-C8rpOS5t.js +0 -1
- package/dist/components/p-CUoPUIej.js +0 -1
- package/dist/components/p-ChpAMqbN.js +0 -1
- package/dist/components/p-D3hr9wra.js +0 -1
- package/dist/components/p-DFybNETX.js +0 -1
- package/dist/components/p-DRmphEA0.js +0 -1
- package/dist/components/p-D_K7tYhY.js +0 -1
- package/dist/components/p-Dw3rv_Y9.js +0 -1
- package/dist/components/p-TNX3alPU.js +0 -1
- package/dist/components/p-j42D1yrQ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,h as a,d as s,t as r,f as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{v as h,a as d,i as p,q as u,r as c,s as v,t as m,h as g,u as f,w as y,x as b,y as S,c as w,z as O,m as T,A,B as D,f as N,C as W}from"./p-Dw3rv_Y9.js";import{w as _}from"./p-CZzlLTQc.js";import{w as C}from"./p-BrQCbmG0.js";import{w as P}from"./p-Bp5Xj4-s.js";import{w as F,a as M,i as R}from"./p-CUoPUIej.js";import{w as j}from"./p-D_K7tYhY.js";import{w as x}from"./p-JG4Sx1lE.js";import{r as I}from"./p-CmvpJzLd.js";import{w as U}from"./p-DRmphEA0.js";import{w as k,r as B}from"./p-D32TsLzd.js";import{g as L}from"./p-Dsvjkuy3.js";import{f as G,r as E,p as z}from"./p-Xb6Ilq8u.js";import{o as J}from"./p-B6kka9sT.js";import{D as $,I as X,d as V,M as Y,B as Z,T as q}from"./p-DFybNETX.js";import{T as Q,a as K,p as H}from"./p-BZXiWkDS.js";import{I as tt,a as it,d as et,c as at}from"./p-CLjuZoiT.js";import{a as st,n as rt}from"./p-j42D1yrQ.js";import{L as nt}from"./p-DY5fMUX8.js";import{o as ot,m as lt}from"./p-DdvG1D18.js";import{r as ht,a as dt}from"./p-CckAR27O.js";import{b as pt}from"./p-JofGXz75.js";import{s as ut}from"./p-DakXa7Dp.js";const ct=t(class extends 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(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.hasSetnameIndexWithoutSetname=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.type="list",this.limit=0,this.thereof="[]",this.thereofPosition="below",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.categoryIntervalPosition=0,this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${G(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${G(i)} percentage points.`}))}},j(this),C(this),this.errors=k(this),P(this),this.componentStyle=x(this),this.ruleSetConfig=U(this),_(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return p(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)})),this.hasSetnameIndexWithoutSetname=Array.isArray(i)&&i.some((t=>{var i,e;return void 0!==at(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&p(null!==(e=null==t?void 0:t.setname)&&void 0!==e?e:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=F(this).t,this.resolveInherited=M(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";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(R(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) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(R(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)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=u(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===E(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===E(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateThereofPosition(t){const i="WARN_thereofPosition";p(t)||y(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"thereofPosition: invalid value '"+t+"' is not supported."})}validatePartOf(t){const i="WARN_partof",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(R(t))return void this.errors.remove(i);const e=S(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";R(t)||w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";T(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){const i="WARN_dataFormatDigitsDecimal";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=D(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===tt||e===it||N(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateCategoryIntervalPosition(t){const i="WARN_categoryIntervalPosition";p(t)||g(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryIntervalPosition: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=W(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validateThereofPosition(this.thereofPosition),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateCategoryIntervalPosition(this.categoryIntervalPosition),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=J(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=L(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){ut(this.element,"bn-table-renderer");const{mode:t}=z(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:a}=L(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=L(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void B(this.errors,null);const{mode:r}=z(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),B(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return $[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareThereofPosition(){var t;return(null===(t=this.thereofPosition)||void 0===t?void 0:t.toLowerCase())===Q.ABOVE?Q.ABOVE:Q.BELOW}prepareTableType(){var t;return K[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>rt(t))),direction:st[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return X.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","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(),...I(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,h,d;const u=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(u.inherited||c.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(u.value)?u.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(u.value.split(",")),(null===(e=c.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(c.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=u.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||u.unresolved;if((p(u.value)||v)&&p(c.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let g=[];return v||p(u.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=u.value)||void 0===l?void 0:l.split(","))),(null===(h=c.value)||void 0===h?void 0:h.trim().length)>0&&(g=g.concat(null===(d=c.value)||void 0===d?void 0:d.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}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"}prepareMeasureType(){var t;return p(this.measureType)?Y.VOLUME:Y[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s="WARN_intervalSetnameIndex",r=p(this.interval)?tt:this.interval.trim().toLowerCase();return r!==tt&&r!==it&&!N(r)||r===tt?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),tt):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),tt):(this.errors.remove(i),r===it?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.hasSetnameIndexWithoutSetname?this.errors.addOrReplace({id:s,type:"warning",message:"interval: rows with setnameIndex but blank setname found, setnameIndex needs setname."}):this.errors.remove(s),this.errors.remove(e),it):(this.errors.remove(a),this.errors.remove(s),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),tt):(this.errors.remove(e),r)))}prepareCategoryIntervalPosition(){const t=Number(this.categoryIntervalPosition);return Number.isInteger(t)&&t>0?t:0}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?H(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=q[i];return e?Z[e]:Z[q.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=E(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=E(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},setNameIndex:{type:"number",isOptional:!0,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return pt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=ot(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,d={version:nt,tag:this.element.localName,id:dt(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:lt(this.element,n),em:{fontSizePx:h,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:ht(this.element),scaling:this.resolveScalingInfo(h),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(d.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),d.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);d.regions=t.regions,d.metadata=Object.assign(Object.assign({},d.metadata),t.metadata),d.diagnostics=[...d.diagnostics,...t.diagnostics],t.elements&&(d.elements=t.elements),t.table&&(d.table=t.table)}}return d}resolveScalingInfo(t){var i,e;const a={},s=E(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=E(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=z(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"2af1b7f31952cd0ba32e0a069ce143d3402b4a77",style:t},a("div",{key:"b78ad13abb48a43c1da0aec4727372a482c39701"},a("bn-table-renderer",{key:"ab0132a3b57953379f6d8f5f19a18f95a14cc326",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereof:this.prepareThereOf(),thereofPosition:this.prepareThereofPosition(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),categoryIntervalPosition:this.prepareCategoryIntervalPosition(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],thereofPosition:[{validateThereofPosition:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}}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)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],runningSum:[4,"running-sum"],varianceWaterfall:[4,"variance-waterfall"],type:[1],limit:[2],thereof:[1],thereofPosition:[1,"thereof-position"],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],categoryIntervalPosition:[2,"category-interval-position"],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],hasSetnameIndexWithoutSetname:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],thereofPosition:[{validateThereofPosition:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}]),vt=ct,mt=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),ct);break;case"bn-table-renderer":customElements.get(r(t))||et()}}))};export{vt as BnTable,mt as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,h as a,d as s,t as r,f as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{v as h,a as d,i as p,q as u,r as c,s as v,t as m,h as g,u as f,w as y,x as b,y as S,c as w,z as O,m as T,A,B as N,f as D,C as W}from"./p-HVN8BNWN.js";import{w as _}from"./p-CZzlLTQc.js";import{w as C}from"./p-BrQCbmG0.js";import{w as M}from"./p-Bp5Xj4-s.js";import{w as F,a as P,i as R}from"./p-DBj1Yd3M.js";import{w as x}from"./p-CVfmhtEW.js";import{w as j}from"./p-JG4Sx1lE.js";import{r as I}from"./p-CmvpJzLd.js";import{w as U}from"./p-x0W2_FAX.js";import{w as B,r as k}from"./p-D32TsLzd.js";import{g as L}from"./p-Dsvjkuy3.js";import{f as G,r as z,p as E}from"./p-Xb6Ilq8u.js";import{o as J}from"./p-B6kka9sT.js";import{D as $,I as X,d as V,M as Y,B as q,T as Z}from"./p-DguYWLBj.js";import{T as Q,a as H,p as K}from"./p-BZXiWkDS.js";import{I as tt,a as it,d as et,c as at}from"./p-B11cXOLy.js";import{a as st,n as rt}from"./p-BBdzTx8V.js";import{L as nt}from"./p-DY5fMUX8.js";import{o as ot,m as lt}from"./p-DdvG1D18.js";import{r as ht,a as dt}from"./p-CckAR27O.js";import{b as pt}from"./p-JofGXz75.js";import{s as ut}from"./p-DakXa7Dp.js";const ct=t(class extends 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(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.hasSetnameIndexWithoutSetname=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.type="list",this.limit=0,this.thereof="[]",this.thereofPosition="below",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.categoryIntervalPosition=0,this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${G(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${G(i)} percentage points.`}))}},x(this),C(this),this.errors=B(this),M(this),this.componentStyle=j(this),this.ruleSetConfig=U(this),_(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return p(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)})),this.hasSetnameIndexWithoutSetname=Array.isArray(i)&&i.some((t=>{var i,e;return void 0!==at(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&p(null!==(e=null==t?void 0:t.setname)&&void 0!==e?e:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=F(this).t,this.resolveInherited=P(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";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(R(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) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(R(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)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=u(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";c(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===z(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===z(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateThereofPosition(t){const i="WARN_thereofPosition";p(t)||y(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"thereofPosition: invalid value '"+t+"' is not supported."})}validatePartOf(t){const i="WARN_partof",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(R(t))return void this.errors.remove(i);const e=S(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";R(t)||w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";T(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){const i="WARN_dataFormatDigitsDecimal";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=N(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===tt||e===it||D(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateCategoryIntervalPosition(t){const i="WARN_categoryIntervalPosition";p(t)||g(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryIntervalPosition: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=W(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validateThereofPosition(this.thereofPosition),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateCategoryIntervalPosition(this.categoryIntervalPosition),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=J(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=L(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){ut(this.element,"bn-table-renderer");const{mode:t}=E(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:a}=L(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled table by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=L(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void k(this.errors,null);const{mode:r}=E(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),k(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return $[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareThereofPosition(){var t;return(null===(t=this.thereofPosition)||void 0===t?void 0:t.toLowerCase())===Q.ABOVE?Q.ABOVE:Q.BELOW}prepareTableType(){var t;return H[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>rt(t))),direction:st[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return X.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","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(),...I(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,h,d;const u=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(u.inherited||c.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(u.value)?u.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(u.value.split(",")),(null===(e=c.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(c.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=u.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||u.unresolved;if((p(u.value)||v)&&p(c.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[];let g=[];return v||p(u.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=u.value)||void 0===l?void 0:l.split(","))),(null===(h=c.value)||void 0===h?void 0:h.trim().length)>0&&(g=g.concat(null===(d=c.value)||void 0===d?void 0:d.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}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"}prepareMeasureType(){var t;return p(this.measureType)?Y.VOLUME:Y[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s="WARN_intervalSetnameIndex",r=p(this.interval)?tt:this.interval.trim().toLowerCase();return r!==tt&&r!==it&&!D(r)||r===tt?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),tt):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(e),this.errors.remove(a),this.errors.remove(s),tt):(this.errors.remove(i),r===it?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.hasSetnameIndexWithoutSetname?this.errors.addOrReplace({id:s,type:"warning",message:"interval: rows with setnameIndex but blank setname found, setnameIndex needs setname."}):this.errors.remove(s),this.errors.remove(e),it):(this.errors.remove(a),this.errors.remove(s),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),tt):(this.errors.remove(e),r)))}prepareCategoryIntervalPosition(){const t=Number(this.categoryIntervalPosition);return Number.isInteger(t)&&t>0?t:0}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],e)=>"string"==typeof i?K(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),e=Z[i];return e?q[e]:q[Z.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=z(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=z(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},setNameIndex:{type:"number",isOptional:!0,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return pt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=ot(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,d={version:nt,tag:this.element.localName,id:dt(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:lt(this.element,n),em:{fontSizePx:h,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:ht(this.element),scaling:this.resolveScalingInfo(h),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(d.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),d.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);d.regions=t.regions,d.metadata=Object.assign(Object.assign({},d.metadata),t.metadata),d.diagnostics=[...d.diagnostics,...t.diagnostics],t.elements&&(d.elements=t.elements),t.table&&(d.table=t.table)}}return d}resolveScalingInfo(t){var i,e;const a={},s=z(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=z(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=E(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"2af1b7f31952cd0ba32e0a069ce143d3402b4a77",style:t},a("div",{key:"b78ad13abb48a43c1da0aec4727372a482c39701"},a("bn-table-renderer",{key:"ab0132a3b57953379f6d8f5f19a18f95a14cc326",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereof:this.prepareThereOf(),thereofPosition:this.prepareThereofPosition(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),categoryIntervalPosition:this.prepareCategoryIntervalPosition(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],thereofPosition:[{validateThereofPosition:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}}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)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],runningSum:[4,"running-sum"],varianceWaterfall:[4,"variance-waterfall"],type:[1],limit:[2],thereof:[1],thereofPosition:[1,"thereof-position"],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],categoryIntervalPosition:[2,"category-interval-position"],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],hasSetnameIndexWithoutSetname:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],thereofPosition:[{validateThereofPosition:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}]),vt=ct,mt=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),ct);break;case"bn-table-renderer":customElements.get(r(t))||et()}}))};export{vt as BnTable,mt as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,f as n,h as o,d as s,t as i}from"./p-BnmylmXF.js";import{w as l}from"./p-CZzlLTQc.js";import{w as a}from"./p-
|
|
1
|
+
import{p as t,H as e,f as n,h as o,d as s,t as i}from"./p-BnmylmXF.js";import{w as l}from"./p-CZzlLTQc.js";import{w as a}from"./p-DBj1Yd3M.js";import{w as r}from"./p-BrQCbmG0.js";import{w as d}from"./p-CVfmhtEW.js";import{w as c}from"./p-JG4Sx1lE.js";import{w as u}from"./p-D32TsLzd.js";import{g as f}from"./p-Dsvjkuy3.js";import{p as v}from"./p-Xb6Ilq8u.js";import{s as h}from"./p-CyUmrWfW.js";const p="[A-Za-z_$\\u00C0-\\uFFFF][\\w$\\u00C0-\\uFFFF]*",m="'[^'\\\\]*'|\"[^\"\\\\]*\"",b=`(?:this\\.)?data(?:\\.(${p})|\\[\\s*(${m})\\s*\\])\\[\\s*(\\d+)\\s*\\]\\.(${p})`,g=RegExp(`\\$\\{\\s*(?:${b}|t\\(\\s*(${m})\\s*(?:,\\s*\\{([^{}]*)\\}\\s*)?\\))\\s*\\}`,"g"),y=RegExp(`\\s*(?:(${p})|(${m}))\\s*:\\s*(?:(${m})|(-?\\d+(?:\\.\\d+)?)|(${b}))\\s*(?:,|$)`,"y"),w=t=>(t+"").replace(/[&<>"'\t\n\f\r ]/g,(t=>`&#${t.charCodeAt(0)};`)),$=(t,e)=>"object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0,N=t=>t.slice(1,-1);const _=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.refit=()=>{n(this)},this.data={},d(this),r(this),this.errors=u(this),this.t=a(this).t,l(this,((t,e)=>{this.data=""===t?{}:Object.assign(Object.assign({},this.data),{[t]:e})})),this.componentStyle=c(this)}connectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.refit)}disconnectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.removeEventListener("loadingdone",this.refit)}validateValue(t){"string"!=typeof t||""===t?this.errors.addOrReplace({id:"WARN_value",type:"warning",message:"Empty value"}):this.errors.remove("WARN_value")}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const e=Number(t);isNaN(e)||e<=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")}componentWillLoad(){this.validateValue(this.value),this.validateScaling(this.scale)}prepareStyle(){return this.componentStyle((t=>{var e,n,o,s,i,l,a,r,d,c,u,f,v,h,p,m,b,g,y,w,$,N;return{fontStyles:{font:`${null!==(s=null!==(n=null===(e=t["bn-text"])||void 0===e?void 0:e.fontSizePx)&&void 0!==n?n:null===(o=t.global)||void 0===o?void 0:o.fontSizePx)&&void 0!==s?s:13.3333}px ${null!==(r=null!==(l=null===(i=t["bn-text"])||void 0===i?void 0:i.fontFamily)&&void 0!==l?l:null===(a=t.global)||void 0===a?void 0:a.fontFamily)&&void 0!==r?r:"'Noto Sans', sans-serif"}`,size:null!==(f=null!==(c=null===(d=t["bn-text"])||void 0===d?void 0:d.fontSizePx)&&void 0!==c?c:null===(u=t.global)||void 0===u?void 0:u.fontSizePx)&&void 0!==f?f:13.3333,color:null!==(m=null!==(h=null===(v=t["bn-text"])||void 0===v?void 0:v.fontColor)&&void 0!==h?h:null===(p=t.global)||void 0===p?void 0:p.fontColor)&&void 0!==m?m:"#000000",background:null!==(w=null!==(g=null===(b=t["bn-text"])||void 0===b?void 0:b.fontBackgroundColor)&&void 0!==g?g:null===(y=t.global)||void 0===y?void 0:y.fontBackgroundColor)&&void 0!==w?w:"#ffffff",leading:null!==(N=null===($=t["bn-text"])||void 0===$?void 0:$.leading)&&void 0!==N?N:1.8}}}))}applyScaling(t){const e=this.element,{mode:n,factor:o}=v(this.scale),{width:s,height:i}=f(e),l=e.scrollHeight>e.clientHeight+1?e.clientHeight:i,a=s,r=a>0&&e.scrollWidth>a+1,d=l>0&&e.scrollHeight>l+1,c=r||d;if(a<=0&&l<=0)return;if("none"===n){if(c){const t=[];r&&t.push(`w:${e.scrollWidth}>${Math.round(a)}`),d&&t.push(`h:${e.scrollHeight}>${Math.round(l)}`),this.errors.addOrReplace({id:"WARN_overflow",type:"warning",message:`Content overflows container (${t.join(", ")})`})}else this.errors.remove("WARN_overflow");return}if("factor"===n){if(c){const t=[];r&&t.push(`w:${e.scrollWidth}>${Math.round(a)}`),d&&t.push(`h:${e.scrollHeight}>${Math.round(l)}`),this.errors.addOrReplace({id:"WARN_overflow",type:"warning",message:`Content overflows with factor ${o} (${t.join(", ")})`})}else this.errors.remove("WARN_overflow");return}e.style.setProperty("--bn-font-size",t+"px");const u=e.scrollWidth,h=e.scrollHeight,p=e.clientHeight,m=h>p+1?p:i,b=a<=0||u<=a+1,g=m<=0||h<=m+1;if(b&&g)return void this.errors.remove("AUTO_scale");const y=Math.min(1,!b&&a>0?a/u:1,!g&&m>0?m/h:1);e.style.setProperty("--bn-font-size",t*y+"px"),"empty"===n?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled font by factor "+y.toFixed(3)}):this.errors.remove("AUTO_scale")}componentDidRender(){var t;const{html:e,unknown:n}=function(t,e,n){const o=[],s=t=>{o.includes(t)||o.push(t)},i=(t,n,o,i,l)=>{const a=$($($(e,null!=n?n:N(o)),Number(i)+""),l);return void 0===a&&s(t),a};return{html:t.replace(g,((t,e,o,l,a,r,d)=>{const c=t.slice(2,-1).trim();try{if(void 0===r){const t=i(c,e,o,l,a);return null==t?"":w(t)}const s=void 0===d?void 0:(t=>{const e={};for(y.lastIndex=0;""!==t.slice(y.lastIndex).trim();){const n=y.exec(t);if(!n)return null;const[,o,s,l,a,r,d,c,u,f]=n;e[null!=o?o:N(s)]=void 0!==l?N(l):void 0!==a?Number(a):i(r,d,c,u,f)}return e})(d);return null===s?t:w(n(N(r),s))}catch(t){return s(c),""}})),unknown:o}}(null!==(t=this.value)&&void 0!==t?t:"",this.data,this.t);n.length>0?this.errors.addOrReplace({id:"WARN_value_path",type:"warning",message:"Unknown template path: "+n.join(", ")}):this.errors.remove("WARN_value_path"),this.container.innerHTML=h(e),this.applyScaling(this.prepareStyle().fontStyles.size)}render(){const{fontStyles:t}=this.prepareStyle(),{mode:e,factor:n}=v(this.scale),i="factor"===e?t.size*n+"px":t.size+"px",l={"--bn-font-family":t.font.substring(t.font.indexOf("px ")+3),"--bn-font-size":i,"--bn-font-color":t.color,"--bn-font-background":t.background};return o(s,{key:"47eaf1468ffc8b8de7e77f2b0aff4b927f8b0471",style:l},o("div",{key:"1f592c2fd0a4af77047c56ee043f6bdd84dfb2d2"},o("span",{key:"ecad3e6ea36dfa495ef78183fc6c3979eb9d5be2",class:"container",ref:t=>{this.container=t}})))}get element(){return this}static get watchers(){return{value:[{validateValue:0}],scale:[{validateScaling:0}]}}static get style(){return':host{padding:0.5em;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);background-color:var(--bn-font-background, white)}span.container p{margin:0}'}},[1,"bn-text",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],value:[1],scale:[1],data:[32]},void 0,{value:[{validateValue:0}],scale:[{validateScaling:0}]}]),j=_,A=function(){"undefined"!=typeof customElements&&["bn-text"].forEach((t=>{"bn-text"===t&&(customElements.get(i(t))||customElements.define(i(t),_))}))};export{j as BnText,A as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-BVNOmHh4.js";const m=o,p=s;export{m as BnTitleRenderer,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{T as o,d as
|
|
1
|
+
import{T as o,d as s}from"./p-y12CmIFS.js";const m=o,p=s;export{m as BnTitle,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,h as n,d as i,t as s}from"./p-BnmylmXF.js";import{o}from"./p-Dw3rv_Y9.js";import{L as r}from"./p-DY5fMUX8.js";import{o as l,m as a}from"./p-DdvG1D18.js";import{r as d,a as c}from"./p-CckAR27O.js";import{w as u}from"./p-BrQCbmG0.js";import{w as h}from"./p-D_K7tYhY.js";import{w as f}from"./p-JG4Sx1lE.js";import{w as p}from"./p-D32TsLzd.js";import{g,a as v}from"./p-Dsvjkuy3.js";import{o as y}from"./p-B6kka9sT.js";const m=["*","/","+","-","x","÷","none"];function b(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function x(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function w(t){return 2*(t-1)+1}function $(t){return 2*(t-1)+1}function S(t){return t<=1?1:2*(t-1)+1}function k(t){return S(t)}function M(t,e){const n=t.getBoundingClientRect(),i=n.left-e.left,s=n.top-e.top;return{left:i,top:s,width:n.width,height:n.height,centerX:i+n.width/2,centerY:s+n.height/2}}function R(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function L(t,e,n,i,s=8){const o=-(i-1)*s/2+n*s;switch(e){case"ltr":return{x:t.left,y:t.centerY+o};case"rtl":return{x:t.left+t.width,y:t.centerY+o};case"ttb":return{x:t.centerX+o,y:t.top};case"btt":return{x:t.centerX+o,y:t.top+t.height}}}function A(t,e,n,i,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let i,s;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;i={x:n,y:t.y},s={x:n,y:e.y}}else{const n=(t.y+e.y)/2;i={x:t.x,y:n},s={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*i.x+.375*s.x+.125*e.x,y:.125*t.y+.375*i.y+.375*s.y+.125*e.y}}}(t,e,i);default:return function(t,e,n,i){let s,o;if("ltr"===n||"rtl"===n){const n=null!=i?i:t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,o={x:n,y:(t.y+e.y)/2}}else{const n=null!=i?i:t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,o={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:o}}(t,e,i,s)}}function j(t,e,n){let i,s,o;switch(n){case"ltr":i=t.left+t.width,s=e.map((t=>t.left)),o=1;break;case"rtl":i=t.left,s=e.map((t=>t.left+t.width)),o=-1;break;case"ttb":i=t.top+t.height,s=e.map((t=>t.top)),o=1;break;case"btt":i=t.top,s=e.map((t=>t.top+t.height)),o=-1}const r=s.map((t=>(t-i)*o)).filter((t=>t>=0));if(0!==r.length)return i+Math.min(...r)*o*.7}function C(t,e,n,i){return"ltr"===i||"rtl"===i?{x:t,y:(e.centerY+n.centerY)/2}:{x:(e.centerX+n.centerX)/2,y:t}}function N(t,e,n){var i,s;return Object.assign({stroke:null!==(i=null==n?void 0:n.color)&&void 0!==i?i:t,strokeWidth:null!==(s=null==n?void 0:n.width)&&void 0!==s?s:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const T=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const i=new Set,s=new Set,o=new Map;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):i.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(i.add(r.to),s.add(r.to),"string"==typeof r.from&&o.set(r.from,[...o.get(r.from)||[],r.to])),void 0!==r.operator&&("string"==typeof r.operator&&m.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${m.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(i).filter((t=>!s.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1?e.push("edges: tree has multiple root nodes: "+r.join(", ")):e.push(...function(t,e,n){const i=[],s=new Set,o=new Set,r=t=>{o.add(t),s.add(t);for(const n of e.get(t)||[])s.has(n)?i.push(`edges: circular reference, the edge from '${t}' to '${n}' leads back`):o.has(n)||r(n);s.delete(t)};r(t);const l=Array.from(n).filter((t=>!o.has(t)));return l.length>0&&i.push(`edges: nodes not connected to the root '${t}': ${l.join(", ")}`),i}(r[0],o,i)),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,i=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),s=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),o=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const i=Array.from(e).filter((t=>!n.has(t)));return 1===i.length?i[0]:null}(n,s);return{edges:n,adjacencyList:i,rootNode:o,allNodes:s}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="WARN_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="WARN_levelSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="WARN_nodeSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="WARN_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.observed=new Set,this.parentObserver=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators=!0,h(this),u(this),this.errors=p(this),this.componentStyle=f(this)}async getLayoutState(t){var e,n,i,s,o,u,h,f,p,g,v;const y=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",m=l(this.element),b=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),x={version:r,tag:this.element.localName,id:c(this.element),slot:null!==(n=this.element.getAttribute("slot"))&&void 0!==n?n:void 0,rect:a(this.element,m),em:{fontSizePx:b,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(s=null===(i=this.treeConfig)||void 0===i?void 0:i.allNodes.size)&&void 0!==s?s:0,edgeCount:null!==(u=null===(o=this.treeConfig)||void 0===o?void 0:o.edges.length)&&void 0!==u?u:0},diagnostics:d(this.element)},w=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if(w&&x.regions.push({id:"grid",rect:a(w,m)}),"full"!==y||!this.treeConfig)return x;const $=[];for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);if(!e)continue;const n={kind:"node",nodeId:t,rect:a(e,m)};$.push(n)}const S=Array.from(null!==(p=null===(f=this.element.shadowRoot)||void 0===f?void 0:f.querySelectorAll("svg.edge-layer path"))&&void 0!==p?p:[]);let k=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const e=S[k++];if(!e)break;const n={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(g=e.getAttribute("d"))&&void 0!==g?g:void 0,rect:a(e,m)};$.push(n)}return null===(v=this.element.shadowRoot)||void 0===v||v.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var e,n;const i=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!i)return;const s={kind:"label",role:"operator",text:i,rect:a(t,m)};$.push(s)})),x.elements=$,x}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle)}connectedCallback(){this.observeLayout(),this.updateNodeRects()}componentDidLoad(){var t;null===(t=this.element.shadowRoot)||void 0===t||t.addEventListener("slotchange",(()=>{this.observeLayout(),this.updateNodeRects()})),requestAnimationFrame((()=>{this.updateNodeRects()}))}componentDidRender(){this.observeLayout(),this.updateNodeRects()}disconnectedCallback(){var t;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.observed.clear(),null===(t=this.parentObserver)||void 0===t||t.disconnect(),this.parentObserver=null}observeLayout(){var t,e,n;const i=null!==(e=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==e?e:null;if(i!==this.gridContainer&&(null===(n=this.resizeObserver)||void 0===n||n.disconnect(),this.observed.clear(),this.gridContainer=i),i){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=y(this.element,(()=>this.checkOverflow())));for(const t of[i,...Array.from(this.element.querySelectorAll("[slot]"))])this.observed.has(t)||(this.resizeObserver.observe(t),this.observed.add(t))}}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,i){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const s=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],i=new Set;for(;n.length>0;){const{node:s,level:o}=n.shift();if(i.has(s))continue;i.add(s),e.set(s,o);const r=t.adjacencyList.get(s)||[];for(const t of r)i.has(t)||n.push({node:t,level:o+1})}return e}(t),o=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function i(s){const o=e.get(s);if(o)return o;const r=t.adjacencyList.get(s)||[];if(e.set(s,{startIndex:n,endIndex:n}),0===r.length){const t={startIndex:n,endIndex:n};return e.set(s,t),n++,t}let l=1/0,a=-1/0;for(const t of r){const e=i(t);l=Math.min(l,e.startIndex),a=Math.max(a,e.endIndex)}const d={startIndex:l,endIndex:a};return e.set(s,d),d}(t.rootNode),e}(t),r=function(t,e,n,i){var s,o;const r=new Map,l=Math.max(...Array.from(e.values()));for(const a of t.allNodes){const d=null!==(s=e.get(a))&&void 0!==s?s:0,c=null!==(o=n.get(a))&&void 0!==o?o:{startIndex:0,endIndex:0};let u,h,f=1,p=1;const g=c.endIndex-c.startIndex+1,v=Array.from(t.allNodes).some((t=>{var i;const s=n.get(t);return t!==a&&void 0!==s&&(null!==(i=e.get(t))&&void 0!==i?i:0)===d&&s.startIndex<=c.endIndex&&c.startIndex<=s.endIndex})),y=v?1:g;switch(i){case"ltr":u=d+1,h=c.startIndex+1,f=g;break;case"rtl":u=l-d+1,h=c.startIndex+1,f=g;break;case"ttb":h=d+1,u=c.startIndex+1,p=y;break;case"btt":h=l-d+1,u=c.startIndex+1,p=y}r.set(a,{nodeId:a,level:d,index:c.startIndex,gridColumn:u,gridRow:h,gridRowSpan:f,gridColumnSpan:p})}return r}(t,s,o,e),l=Math.max(...Array.from(s.values())),a=Math.max(...Array.from(o.values()).map((t=>t.endIndex))),{gridTemplateColumns:d,gridTemplateRows:c}=function(t,e,n,i,s){const o=t+1,r=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(l,a,e,n,i);return{positions:r,gridTemplateColumns:d,gridTemplateRows:c,maxLevel:l,maxIndex:a}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){var t;if(!this.treeConfig||!this.gridContainer)return void(null===(t=this.errors)||void 0===t||t.remove("WARN_overflow"));const e=this.gridContainer.getBoundingClientRect(),n=new Map;for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);i&&n.set(t,M(i,e))}(function(t,e){if(t.size!==e.size)return!1;for(const[n,i]of t){const t=e.get(n);if(!t||t.left!==i.left||t.top!==i.top||t.width!==i.width||t.height!==i.height)return!1}return!0})(this.nodeRects,n)||(this.nodeRects=n),this.svgWidth=e.width,this.svgHeight=e.height,this.checkOverflow()}checkOverflow(){var t,e;const n="WARN_overflow",i=g(this.element),s=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,o=(null===(e=this.gridContainer)||void 0===e?void 0:e.scrollHeight)||0,r=[];i.width>0&&s>i.width+1&&r.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`);const l=v(this.element,o);l>1&&r.push(`height (${Math.round(o)}px > ${Math.round(o-l)}px)`),0!==r.length?this.errors.addOrReplace({id:n,type:"warning",message:`Tree exceeds available ${r.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(n)}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":w(e.gridColumn)+"","grid-row":`${$(e.gridRow)} / span ${S(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":$(e.gridRow)+"","grid-column":`${w(e.gridColumn)} / span ${k(e.gridColumnSpan)}`,"justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),i=[],s=[],o=new Map;for(const t of this.treeConfig.edges){const e=o.get(t.to)||[];e.push(t.from),o.set(t.to,e)}const r=new Map;for(const[t,e]of this.treeConfig.adjacencyList.entries()){const n=this.nodeRects.get(t),i=e.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),s=n?j(n,i,this.direction):void 0;void 0!==s&&r.set(t,s)}for(const t of this.treeConfig.edges){const s=this.nodeRects.get(t.from),l=this.nodeRects.get(t.to);if(!s||!l)continue;const a=R(s,!0,this.direction),d=o.get(t.to)||[];let c;if(d.length>1){const e=d.indexOf(t.from);c=L(l,this.direction,e,d.length)}else c=R(l,!1,this.direction);const{path:u}=A(a,c,this.edgeStyle,this.direction,r.get(t.from)),h=N(e.edgeColor,e.edgeWidth,t.style);i.push(n("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:h.stroke,"stroke-width":h.strokeWidth,"stroke-dasharray":h.strokeDasharray}))}if(this.showOperators)for(const[i,o]of this.treeConfig.adjacencyList.entries()){const l=r.get(i);if(void 0!==l)for(let r=0;r<o.length-1;r++){const a=o[r],d=o[r+1],c=x(this.treeConfig.edges,i,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),h=this.nodeRects.get(d);if(!u||!h)continue;const f=null!==(t=c.label)&&void 0!==t?t:b(c.operator),p=C(l,u,h,this.direction);s.push(n("g",{key:`operator-${i}-${a}`,class:"operator-group"},n("circle",{cx:p.x,cy:p.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:p.x,y:p.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},f)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},i,s)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node","data-bn-fit-content":"",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,i,s;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(i=t.global)||void 0===i?void 0:i.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(i,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{selectedStyle:[513,"selected-style"],edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[4,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32],getLayoutState:[64]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}]),D=T,E=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(s(t))||customElements.define(s(t),T))}))};export{D as BnTree,E as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,h as n,d as i,t as s}from"./p-BnmylmXF.js";import{o}from"./p-HVN8BNWN.js";import{L as r}from"./p-DY5fMUX8.js";import{o as l,m as a}from"./p-DdvG1D18.js";import{r as d,a as c}from"./p-CckAR27O.js";import{w as u}from"./p-BrQCbmG0.js";import{w as h}from"./p-CVfmhtEW.js";import{w as f}from"./p-JG4Sx1lE.js";import{w as p}from"./p-D32TsLzd.js";import{g,a as v}from"./p-Dsvjkuy3.js";import{o as m}from"./p-B6kka9sT.js";const y=["*","/","+","-","x","÷","none"];function b(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function x(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function $(t){return 2*(t-1)+1}function w(t){return 2*(t-1)+1}function S(t){return t<=1?1:2*(t-1)+1}function k(t){return S(t)}function M(t,e){const n=t.getBoundingClientRect(),i=n.left-e.left,s=n.top-e.top;return{left:i,top:s,width:n.width,height:n.height,centerX:i+n.width/2,centerY:s+n.height/2}}function R(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function L(t,e,n,i,s=8){const o=-(i-1)*s/2+n*s;switch(e){case"ltr":return{x:t.left,y:t.centerY+o};case"rtl":return{x:t.left+t.width,y:t.centerY+o};case"ttb":return{x:t.centerX+o,y:t.top};case"btt":return{x:t.centerX+o,y:t.top+t.height}}}function N(t,e,n,i,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let i,s;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;i={x:n,y:t.y},s={x:n,y:e.y}}else{const n=(t.y+e.y)/2;i={x:t.x,y:n},s={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*i.x+.375*s.x+.125*e.x,y:.125*t.y+.375*i.y+.375*s.y+.125*e.y}}}(t,e,i);default:return function(t,e,n,i){let s,o;if("ltr"===n||"rtl"===n){const n=null!=i?i:t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,o={x:n,y:(t.y+e.y)/2}}else{const n=null!=i?i:t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,o={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:o}}(t,e,i,s)}}function A(t,e,n){let i,s,o;switch(n){case"ltr":i=t.left+t.width,s=e.map((t=>t.left)),o=1;break;case"rtl":i=t.left,s=e.map((t=>t.left+t.width)),o=-1;break;case"ttb":i=t.top+t.height,s=e.map((t=>t.top)),o=1;break;case"btt":i=t.top,s=e.map((t=>t.top+t.height)),o=-1}const r=s.map((t=>(t-i)*o)).filter((t=>t>=0));if(0!==r.length)return i+Math.min(...r)*o*.7}function C(t,e,n,i){return"ltr"===i||"rtl"===i?{x:t,y:(e.centerY+n.centerY)/2}:{x:(e.centerX+n.centerX)/2,y:t}}function j(t,e,n){var i,s;return Object.assign({stroke:null!==(i=null==n?void 0:n.color)&&void 0!==i?i:t,strokeWidth:null!==(s=null==n?void 0:n.width)&&void 0!==s?s:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const T=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const i=new Set,s=new Set,o=new Map;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):i.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(i.add(r.to),s.add(r.to),"string"==typeof r.from&&o.set(r.from,[...o.get(r.from)||[],r.to])),void 0!==r.operator&&("string"==typeof r.operator&&y.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${y.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(i).filter((t=>!s.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1?e.push("edges: tree has multiple root nodes: "+r.join(", ")):e.push(...function(t,e,n){const i=[],s=new Set,o=new Set,r=t=>{o.add(t),s.add(t);for(const n of e.get(t)||[])s.has(n)?i.push(`edges: circular reference, the edge from '${t}' to '${n}' leads back`):o.has(n)||r(n);s.delete(t)};r(t);const l=Array.from(n).filter((t=>!o.has(t)));return l.length>0&&i.push(`edges: nodes not connected to the root '${t}': ${l.join(", ")}`),i}(r[0],o,i)),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,i=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),s=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),o=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const i=Array.from(e).filter((t=>!n.has(t)));return 1===i.length?i[0]:null}(n,s);return{edges:n,adjacencyList:i,rootNode:o,allNodes:s}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="WARN_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="WARN_levelSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="WARN_nodeSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="WARN_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.observed=new Set,this.parentObserver=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators=!0,h(this),u(this),this.errors=p(this),this.componentStyle=f(this)}async getLayoutState(t){var e,n,i,s,o,u,h,f,p,g,v;const m=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",y=l(this.element),b=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),x={version:r,tag:this.element.localName,id:c(this.element),slot:null!==(n=this.element.getAttribute("slot"))&&void 0!==n?n:void 0,rect:a(this.element,y),em:{fontSizePx:b,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(s=null===(i=this.treeConfig)||void 0===i?void 0:i.allNodes.size)&&void 0!==s?s:0,edgeCount:null!==(u=null===(o=this.treeConfig)||void 0===o?void 0:o.edges.length)&&void 0!==u?u:0},diagnostics:d(this.element)},$=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if($&&x.regions.push({id:"grid",rect:a($,y)}),"full"!==m||!this.treeConfig)return x;const w=[];for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);if(!e)continue;const n={kind:"node",nodeId:t,rect:a(e,y)};w.push(n)}const S=Array.from(null!==(p=null===(f=this.element.shadowRoot)||void 0===f?void 0:f.querySelectorAll("svg.edge-layer path"))&&void 0!==p?p:[]);let k=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const e=S[k++];if(!e)break;const n={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(g=e.getAttribute("d"))&&void 0!==g?g:void 0,rect:a(e,y)};w.push(n)}return null===(v=this.element.shadowRoot)||void 0===v||v.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var e,n;const i=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!i)return;const s={kind:"label",role:"operator",text:i,rect:a(t,y)};w.push(s)})),x.elements=w,x}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle)}connectedCallback(){this.observeLayout(),this.updateNodeRects()}componentDidLoad(){var t;null===(t=this.element.shadowRoot)||void 0===t||t.addEventListener("slotchange",(()=>{this.observeLayout(),this.updateNodeRects()})),requestAnimationFrame((()=>{this.updateNodeRects()}))}componentDidRender(){this.observeLayout(),this.updateNodeRects()}disconnectedCallback(){var t;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.observed.clear(),null===(t=this.parentObserver)||void 0===t||t.disconnect(),this.parentObserver=null}observeLayout(){var t,e,n;const i=null!==(e=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==e?e:null;if(i!==this.gridContainer&&(null===(n=this.resizeObserver)||void 0===n||n.disconnect(),this.observed.clear(),this.gridContainer=i),i){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=m(this.element,(()=>this.checkOverflow())));for(const t of[i,...Array.from(this.element.querySelectorAll("[slot]"))])this.observed.has(t)||(this.resizeObserver.observe(t),this.observed.add(t))}}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,i){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const s=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],i=new Set;for(;n.length>0;){const{node:s,level:o}=n.shift();if(i.has(s))continue;i.add(s),e.set(s,o);const r=t.adjacencyList.get(s)||[];for(const t of r)i.has(t)||n.push({node:t,level:o+1})}return e}(t),o=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function i(s){const o=e.get(s);if(o)return o;const r=t.adjacencyList.get(s)||[];if(e.set(s,{startIndex:n,endIndex:n}),0===r.length){const t={startIndex:n,endIndex:n};return e.set(s,t),n++,t}let l=1/0,a=-1/0;for(const t of r){const e=i(t);l=Math.min(l,e.startIndex),a=Math.max(a,e.endIndex)}const d={startIndex:l,endIndex:a};return e.set(s,d),d}(t.rootNode),e}(t),r=function(t,e,n,i){var s,o;const r=new Map,l=Math.max(...Array.from(e.values()));for(const a of t.allNodes){const d=null!==(s=e.get(a))&&void 0!==s?s:0,c=null!==(o=n.get(a))&&void 0!==o?o:{startIndex:0,endIndex:0};let u,h,f=1,p=1;const g=c.endIndex-c.startIndex+1,v=Array.from(t.allNodes).some((t=>{var i;const s=n.get(t);return t!==a&&void 0!==s&&(null!==(i=e.get(t))&&void 0!==i?i:0)===d&&s.startIndex<=c.endIndex&&c.startIndex<=s.endIndex})),m=v?1:g;switch(i){case"ltr":u=d+1,h=c.startIndex+1,f=g;break;case"rtl":u=l-d+1,h=c.startIndex+1,f=g;break;case"ttb":h=d+1,u=c.startIndex+1,p=m;break;case"btt":h=l-d+1,u=c.startIndex+1,p=m}r.set(a,{nodeId:a,level:d,index:c.startIndex,gridColumn:u,gridRow:h,gridRowSpan:f,gridColumnSpan:p})}return r}(t,s,o,e),l=Math.max(...Array.from(s.values())),a=Math.max(...Array.from(o.values()).map((t=>t.endIndex))),{gridTemplateColumns:d,gridTemplateRows:c}=function(t,e,n,i,s){const o=t+1,r=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(l,a,e,n,i);return{positions:r,gridTemplateColumns:d,gridTemplateRows:c,maxLevel:l,maxIndex:a}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){var t;if(!this.treeConfig||!this.gridContainer)return void(null===(t=this.errors)||void 0===t||t.remove("WARN_overflow"));const e=this.gridContainer.getBoundingClientRect(),n=new Map;for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);i&&n.set(t,M(i,e))}(function(t,e){if(t.size!==e.size)return!1;for(const[n,i]of t){const t=e.get(n);if(!t||t.left!==i.left||t.top!==i.top||t.width!==i.width||t.height!==i.height)return!1}return!0})(this.nodeRects,n)||(this.nodeRects=n),this.svgWidth=e.width,this.svgHeight=e.height,this.checkOverflow()}checkOverflow(){var t,e;const n="WARN_overflow",i=g(this.element),s=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,o=(null===(e=this.gridContainer)||void 0===e?void 0:e.scrollHeight)||0,r=[];i.width>0&&s>i.width+1&&r.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`);const l=v(this.element,o);l>1&&r.push(`height (${Math.round(o)}px > ${Math.round(o-l)}px)`),0!==r.length?this.errors.addOrReplace({id:n,type:"warning",message:`Tree exceeds available ${r.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(n)}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":$(e.gridColumn)+"","grid-row":`${w(e.gridRow)} / span ${S(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":w(e.gridRow)+"","grid-column":`${$(e.gridColumn)} / span ${k(e.gridColumnSpan)}`,"justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),i=[],s=[],o=new Map;for(const t of this.treeConfig.edges){const e=o.get(t.to)||[];e.push(t.from),o.set(t.to,e)}const r=new Map;for(const[t,e]of this.treeConfig.adjacencyList.entries()){const n=this.nodeRects.get(t),i=e.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),s=n?A(n,i,this.direction):void 0;void 0!==s&&r.set(t,s)}for(const t of this.treeConfig.edges){const s=this.nodeRects.get(t.from),l=this.nodeRects.get(t.to);if(!s||!l)continue;const a=R(s,!0,this.direction),d=o.get(t.to)||[];let c;if(d.length>1){const e=d.indexOf(t.from);c=L(l,this.direction,e,d.length)}else c=R(l,!1,this.direction);const{path:u}=N(a,c,this.edgeStyle,this.direction,r.get(t.from)),h=j(e.edgeColor,e.edgeWidth,t.style);i.push(n("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:h.stroke,"stroke-width":h.strokeWidth,"stroke-dasharray":h.strokeDasharray}))}if(this.showOperators)for(const[i,o]of this.treeConfig.adjacencyList.entries()){const l=r.get(i);if(void 0!==l)for(let r=0;r<o.length-1;r++){const a=o[r],d=o[r+1],c=x(this.treeConfig.edges,i,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),h=this.nodeRects.get(d);if(!u||!h)continue;const f=null!==(t=c.label)&&void 0!==t?t:b(c.operator),p=C(l,u,h,this.direction);s.push(n("g",{key:`operator-${i}-${a}`,class:"operator-group"},n("circle",{cx:p.x,cy:p.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:p.x,y:p.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},f)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},i,s)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node","data-bn-fit-content":"",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,i,s;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(i=t.global)||void 0===i?void 0:i.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(i,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{selectedStyle:[513,"selected-style"],edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[4,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32],getLayoutState:[64]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}]),E=T,W=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(s(t))||customElements.define(s(t),T))}))};export{E as BnTree,W as defineCustomElement}
|