import{a as e}from"./rolldown-runtime-C_ttsnZz.js";import{t}from"./CaretDown.es-B7BqSg6P.js";import{t as r}from"./ScoreIcon-jTADH_fU.js";import{St as s,q as a}from"./index-BT8Vuu3B.js";import{t as i}from"./bundle-mjs-orX75hSI.js";var n=e(s(),1),o=a(),c=n.createContext({}),d=({children:e})=>{const[t,r]=(0,n.useState)("");return(0,o.jsx)(c.Provider,{value:{activeScore:t,setActiveScore:r},children:e})},l="\n  flex items-center justify-between w-full\n  transition-colors py-1.5 px-3\n\n  data-[expandable=true]:cursor-pointer\n  data-[expandable=true]:hover:bg-gray-100\n";function u({scoreKey:e,onClick:t,children:r}){return void 0===t?(0,o.jsx)("div",{"data-testid":`score-card-container-${e}`,className:l,children:r}):(0,o.jsx)("button",{"data-testid":`score-card-container-${e}`,className:l,"data-expandable":!0,onClick:()=>t(e),children:r})}function x({isExpandable:e}){return e?(0,o.jsx)(t,{"data-testid":"expand-toggle-icon",className:"h-2.5 w-2.5 mr-2 group-data-[active=true]:rotate-180 transition-transform duration-50 ease-in-out"}):null}function m({scoreKey:e,children:t}){return(0,o.jsxs)("div",{className:"flex items-center justify-between grow font-medium","data-testid":"score-card-title",children:[(0,o.jsx)(r,{score:e,className:"flex h-4 w-4 mr-2"}),(0,o.jsx)("p",{className:"grow mr-2 w-20 text-left truncate text-ellipsis overflow-hidden text-xs","data-testid":"score-card-title-text",children:t})]})}function p({scoreValue:e}){const t=(0,n.useMemo)(()=>{let t=Number(e);return isNaN(t)&&(t=0),Math.round(10*t)/10*2},[e]);return(0,o.jsx)("div",{className:"bg-gray-400 text-base-white font-medium py-1 px-2.5 text-xs rounded w-10 text-center group-data-[active=true]:bg-primary-100 transition-colors","data-testid":"score-card-value",children:t})}function h({isVisible:e,children:t}){return e?(0,o.jsx)("div",{"data-testid":"score-card-description",className:"py-1.5 px-3 ml-5 text-xs font-normal",children:t}):null}var j=({title:e,scoreKey:t,value:r,description:s,onClick:a})=>{const{activeScore:i,setActiveScore:d}=(0,n.useContext)(c);return(0,o.jsxs)("div",{className:"group rounded border border-gray-150 bg-base-white  overflow-hidden mb-1 last:mb-0","data-active":i===t,"data-testid":"score-card","data-score":t,children:[(0,o.jsxs)(u,{scoreKey:t,onClick:s?e=>{s&&(d(i!==e?e:""),void 0!==a&&a(e,i!==e))}:void 0,children:[(0,o.jsx)(x,{isExpandable:!!s}),(0,o.jsx)(m,{scoreKey:t,children:e}),(0,o.jsx)(p,{scoreValue:r})]}),(0,o.jsx)(h,{isVisible:t===i,children:s})]})},v=({className:e,children:t})=>(0,o.jsx)(d,{children:(0,o.jsx)("div",{className:i("text-gray-400",e),children:t})});export{j as n,v as t};
//# sourceMappingURL=ScoreCardList-SU186XV-.js.map