import{__rest as e}from"tslib";import t from"react";import{twMerge as a}from"tailwind-merge";import{BaseColors as r}from"../../../lib/constants.js";import{borderRadius as l}from"../../../lib/shape.js";import{sizing as m}from"../../../lib/sizing.js";import{spacing as n}from"../../../lib/spacing.js";import{fontSize as o}from"../../../lib/font.js";import{colorPalette as i,DEFAULT_COLOR as s}from"../../../lib/theme.js";import{getColorClassNames as c,makeClassName as f,defaultValueFormatter as u}from"../../../lib/utils.js";const h=f("BarList"),p=t.forwardRef(((f,p)=>{const{data:d=[],color:g=r.Blue,valueFormatter:b=u,showAnimation:x=!0,className:v}=f,w=e(f,["data","color","valueFormatter","showAnimation","className"]),N=(e=>{let t=-1/0;return e.forEach((e=>{t=Math.max(t,e)})),e.map((e=>0===e?0:Math.max(e/t*100,1)))})(d.map((e=>e.value))),E=m.threeXl.height;return t.createElement("div",Object.assign({ref:p,className:a(h("root"),"flex justify-between",n.threeXl.spaceX,v)},w),t.createElement("div",{className:a(h("bars"),"relative w-full")},d.map(((e,r)=>{var f,u,p;const b=e.icon;return t.createElement("div",{key:null!==(f=e.key)&&void 0!==f?f:e.name,className:a(h("bar"),"flex items-center",E,c(null!==(u=e.color)&&void 0!==u?u:g,i.lightBackground).bgColor,l.sm.all,r===d.length-1?n.none.marginBottom:n.sm.marginBottom),style:{width:`${N[r]}%`,transition:x?"all 2s":""}},t.createElement("div",{className:a("absolute max-w-full flex",n.sm.left)},b?t.createElement(b,{className:a(h("barIcon"),"flex-none",m.lg.height,m.lg.width,n.md.marginRight,c(s,i.lightText).textColor),"aria-hidden":"true"}):null,e.href?t.createElement("a",{href:e.href,target:null!==(p=e.target)&&void 0!==p?p:"_blank",rel:"noreferrer",className:a(h("barLink"),"whitespace-nowrap truncate text-blue-500","no-underline hover:underline visited:text-blue-500",o.sm)},e.name):t.createElement("p",{className:a(h("barText"),"whitespace-nowrap truncate",c(s,i.darkText).textColor,o.sm)},e.name)))}))),t.createElement("div",{className:"text-right min-w-min"},d.map(((e,r)=>{var l;return t.createElement("div",{key:null!==(l=e.key)&&void 0!==l?l:e.name,className:a(h("labelWrapper"),"flex justify-end items-center",E,r===d.length-1?n.none.marginBottom:n.sm.marginBottom)},t.createElement("p",{className:a(h("labelText"),"whitespace-nowrap truncate",c(s,i.darkText).textColor,o.sm)},b(e.value)))}))))}));p.displayName="BarList";export{p as default};
