"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("react"),i=require("./Utils.js"),T=V=>{const{children:f,data:u,measures:y,locale:n,customLabels:b}=V,c=new Set,h=new Set,g=i.measuresMap(u);if(u&&u.children){const v=[],s=i.typesMap(u),p=[];u.children.forEach(e=>{if(c.add(s[e.type]),e.children)e.children.forEach(a=>{const l=new Object,o=new Object;o[e.type]=i.getTranslatedValue(s[e.type].items.filter(t=>t.value===e.value)[0],n)||e.value,o[a.type]=i.getTranslatedValue(s[a.type].items.filter(t=>t.value===a.value)[0],n)||a.value,Object.keys(a).forEach(t=>{o[t]=a[t]}),l.id=i.getTranslatedValue(s[e.type].items.filter(t=>t.value===e.value)[0],n)+" - "+i.getTranslatedValue(s[a.type].items.filter(t=>t.value===a.value)[0],n),p.push(e.value+" - "+a.value),l.value=a[y[0]],l.label=i.getTranslatedValue(s[e.type].items.filter(t=>t.value===e.value)[0],n)+" - "+i.getTranslatedValue(s[a.type].items.filter(t=>t.value===a.value)[0],n),l.variables=o,v.push(l);let r=Array.from(c).find(t=>t.dimension===a.type)||{...s[a.type]};Array.from(c).some(t=>t.dimension===a.type)||c.add(r);let w=r.items.find(t=>t.id===l.id)||{dimension:a.type,type:a.type,categoryStyle:{color:"#484848"},position:0,labels:{},code:l.id,value:l.id,id:l.id};r.items.some(t=>t.id===l.id)||r.items.push(w)});else{const a=s[e.type].items.filter(r=>r.value===e.value)[0],l=new Object,o=new Object;o[e.type]=i.getTranslatedValue(a,n)||e.value,Object.keys(u).forEach(r=>{o[r]=e[r]}),c.add(s[e.type]),l.id=i.getTranslatedValue(a,n)||e.value,l.label=i.getTranslatedValue(a,n)||e.value,l.position=a.position||0,l.value=e[y[0]],l.variables=o,v.push(l)}});const d={indexBy:"id",keys:[],measuresMetadata:h,dimensionsMetadata:c,data:v.sort((e,a)=>a.value-e.value),metadata:u.metadata};return m.Children.map(f,e=>m.cloneElement(e,{options:d}))}else{const v=u.metadata.measures.filter(e=>y.includes(e.value)),s=[],p={};Object.keys(u).forEach(e=>{p[e]=u[e]}),v.forEach(e=>{const a={};a.type="measure",a.measureFieldName=e.value,a.id=b[e.value]||i.getTranslatedValue(g[e.value],n),a.position=e.position,a.label=b[e.value]||i.getTranslatedValue(g[e.value],n),a.value=u[e.value],a.variables=p,s.push(a)});const d={indexBy:"id",keys:[],measuresMetadata:h,dimensionsMetadata:c,data:s.sort((e,a)=>a.value-e.value),metadata:u.metadata};return m.Children.map(f,e=>m.cloneElement(e,{options:d}))}};exports.PieData=T;exports.default=T;
