"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),F=require("react"),G=require("semantic-ui-react"),H=require("../data/DataProvider.js"),J=require("../data/DataConsumer.js");require("@devgateway/wp-react-lib");const K=require("react-redux"),R=require("@react-spring/web"),$=o=>{const{editing:t=!1,unique:n,intl:a,childContent:m,"data-csv":S="","data-dimension1":b="none","data-dvz-proxy-dataset-id":y,"data-no-data-message":j="No data matches your selection","data-view-mode":D="info","data-height":p,"data-app":r,"data-measures":i="{}","data-format":v="{}","data-group":g,"data-filters":f="[]","data-number-font-size":x=20,"data-label-font-size":s=20,"data-number-color":c="#000000","data-label-color":d="#000000","data-label":h="","data-group-label":O="","data-group-label-color":P="","data-group-label-font-size":T="","data-wait-for-filters":U="false","data-no-data-text":I="-"}=o,A=a.locale,E=F.useRef(null),V=l=>t?l:decodeURIComponent(l),z=l=>{try{return JSON.parse(V(l))}catch{console.error("error parsing value:"+l)}return null},N=z(i),u=N&&N[r]?N[r].format:null;console.log(u);const _=u?{style:u.style==="compacted"?"decimal":u.style,notation:u.style==="compacted"?"compact":"standard",currency:u.currency,minimumFractionDigits:parseInt(u.minimumFractionDigits),maximumFractionDigits:parseInt(u.maximumFractionDigits)}:{notation:"standard",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2},[Z,k]=F.useState(D),B=t?p-80:p-40,C={},L=z(f)||{};L&&L.forEach&&L.forEach(l=>{l.value!=null&&l.value.filter(w=>w!=null&&w.toString().trim()!="").length>0&&(C[l.param]=l.value)}),y&&(C.dvzProxyDatasetId=y);const q=[];return b!="none"&&q.push(b),e.jsx("div",{ref:E,children:e.jsx(G.Container,{className:"chart container big-number-container",style:{height:p+"px"},fluid:!0,children:r&&r!="none"&&e.jsx(H.default,{style:{height:`${B}px`},params:C,app:r,group:g,source:q.join("/"),csv:S,editing:t,waitForFilters:U==="true",store:[r,n,...q],children:e.jsx(J.default,{children:e.jsx(Q,{dimension:b,locale:A,intl:a,app:r,format:_,measures:z(i),label:h,numberFontSize:x,numberColor:c,labelFontSize:s,labelColor:d,noDataText:I,groupLabel:O,groupLabelColor:P,groupLabelFontSize:T})})})})})},Q=o=>{const{app:t,measures:n,data:a,format:m,label:S,numberColor:b,numberFontSize:y,dimension:j,labelColor:D,labelFontSize:p,noDataText:r="-",intl:i,groupLabel:v,groupLabelColor:g,groupLabelFontSize:f}=o,x=n&&n[t]?Object.keys(n[t]).filter(s=>n[t][s].selected):[];if(j!="none"){const s=a.metadata.types.filter(c=>c.dimension===j)[0];return a.children.map(c=>{const d=s.items.filter(h=>h.code==c.value)[0].value;return e.jsxs("div",{className:"big-number-group",style:{display:"flex",flexDirection:"column"},children:[e.jsxs("span",{className:"big-number-title",style:{color:g,fontSize:f+"px"},children:[e.jsx("span",{className:"dimension-text",children:d}),e.jsxs("span",{className:"group-text",children:[" ",v]})]}),e.jsx("div",{className:"big-number-row",style:{display:"flex",flexDirection:"row"},children:x.map(h=>e.jsx("div",{className:"big-number-parent",children:e.jsx(M,{showDimensionLabel:!0,metadata:s,dataItem:c,measureField:h,measure:n[t][h],...o})}))})]})})}else return e.jsxs("div",{children:[e.jsxs("span",{style:{color:g,fontSize:f+"px"},children:[" ",v]}),x.map(s=>e.jsx(M,{dataItem:a,measureField:s,measure:n[t][s],...o}))]})},M=({dataItem:o,format:t,measureField:n,measure:a,numberColor:m,numberFontSize:S,labelColor:b,labelFontSize:y,noDataText:j,label:D,intl:p})=>{const r=(o==null?void 0:o[n])??null,i=r?(t==null?void 0:t.style)==="percent"?r/100:r:null,[v,g]=F.useState(i);F.useEffect(()=>{i!=null&&g(i)},[i]);const{number:f}=R.useSpring({from:{number:0},to:{number:v??0},config:{mass:1,tension:120,friction:30}}),x={color:decodeURIComponent(m),fontSize:S+"px",textAlign:"center"},s={color:decodeURIComponent(b),fontSize:y+"px",textAlign:"center"},c=d=>p.formatNumber(d,{...t});return e.jsxs("div",{className:"big-number",children:[e.jsx("div",{style:x,className:"big-number-value",children:i===null?j:e.jsx(R.animated.span,{children:f.to(d=>c(d))})}),(a==null?void 0:a.customLabel)&&e.jsx("div",{style:s,className:"big-number-label",children:a.customLabel})]})},W=(o,t)=>{const{"data-app":n,"data-group":a}=t,m=o.getIn(["data","measures",n,a]);return m?{injectedMeasures:m}:{}},X={},Y=K.connect(W,X)($);exports.default=Y;
