import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as a,ki as r}from"./vendor-frame-CwiylG4Y.js";import{bt as t,ct as l,it as i}from"./shared-frame-DbQbH4Yr.js";import{oo as s}from"./shared-4-6CEyRAHb.js";var n=e(a()),o=r(),d=`inset 0 0 0 1px ${s.alpha[1].cssVar}`,c={accent:"bg-accent",success:"bg-success",warning:"bg-warning",danger:"bg-danger"},u={accent:"bg-fill-accent",success:"bg-fill-success",warning:"bg-fill-warning",danger:"bg-fill-danger"},b=(s.fill.accent,s.text.accent,s.fill.success,s.text.success,s.fill.warning,s.text.warning,s.fill.danger,s.text.danger,new Map);var m=(0,n.createContext)(null);function f(e){const a=(0,n.useContext)(m);if(null===a)throw new Error(`Meter.${e} must be rendered inside <Meter.Root>.`);return a}var v=(0,n.forwardRef)(({value:e,min:a=0,max:r=1,variant:i="accent",valueText:s,locale:d,size:c,className:u,children:f,"aria-label":v,"aria-labelledby":x,"aria-describedby":g,...y},N)=>{const p=(0,n.useId)(),L=(0,n.useRef)(!1);(0,n.useRef)(!1),(0,n.useRef)(!1),(0,n.useRef)(!1);const[j,R]=(0,n.useState)(null),A=(0,n.useCallback)(e=>{L.current=null!==e,R(e)},[]),I=r-a,T=!(I>0&&Number.isFinite(I)),F=null!==e&&!Number.isFinite(e),z=null===e||T||F,V=z?0:(e-a)/I,M=V<0?0:V>1?1:V,k=z||null===e?void 0:e<a?a:e>r?r:e,D=l(),C=(d?.trim()?d.trim():void 0)??D,E=z?void 0:s??function(e){let a=b.get(e);return a||(a=new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:0}),b.set(e,a)),a}(C).format(V),S=!z&&V!==M;(0,n.useEffect)(()=>{},[T,F,z,e,a,r,v,x]);const $=(0,n.useMemo)(()=>({isNull:z,clampedFraction:M,ariaValueNow:k,min:a,max:r,variant:i,valueText:E,emitValueText:void 0!==s||S,rootAriaLabel:v,rootAriaLabelledby:x,rootAriaDescribedby:g,labelId:p,size:c,registeredLabelId:j,registerLabel:A}),[z,M,k,a,r,i,E,s,S,v,x,g,p,c,j,A]);return(0,o.jsx)("div",{ref:N,"data-cds":"Meter","data-variant":i,...y,className:t("w-full",u),children:(0,o.jsx)(m.Provider,{value:$,children:f??(0,o.jsx)(w,{children:(0,o.jsx)(h,{})})})})}),x=(0,n.forwardRef)(({className:e,id:a,...r},l)=>{const i=f("Label"),{registerLabel:s}=i,d=a??i.labelId;return(0,n.useEffect)(()=>(s(d),()=>{s(null)}),[s,d]),(0,o.jsx)("span",{ref:l,...r,id:d,className:t("text-body font-medium text-primary",e)})}),g=(0,n.forwardRef)(({className:e,...a},r)=>{const l=f("Value");return void 0===l.valueText?null:(0,o.jsx)("span",{ref:r,...a,className:t("text-footnote text-secondary tabular-nums whitespace-nowrap text-end",e),children:l.valueText})}),w=(0,n.forwardRef)(({className:e,children:a,style:r,...l},s)=>{const n=f("Track"),u=n.isNull||n.clampedFraction<=0,b=n.isNull?{"aria-hidden":!0}:{role:"meter","aria-valuemin":n.min,"aria-valuemax":n.max,"aria-valuenow":n.ariaValueNow,...n.emitValueText&&void 0!==n.valueText?{"aria-valuetext":n.valueText}:{},...void 0!==n.rootAriaLabel?{"aria-label":n.rootAriaLabel}:{},...void 0!==n.rootAriaLabelledby?{"aria-labelledby":n.rootAriaLabelledby}:void 0===n.rootAriaLabel&&null!==n.registeredLabelId?{"aria-labelledby":n.registeredLabelId}:{},...void 0!==n.rootAriaDescribedby?{"aria-describedby":n.rootAriaDescribedby}:{}};return(0,o.jsx)("div",{ref:s,...l,"data-variant":n.variant,...i(n.size),...b,className:t("w-full overflow-hidden rounded-full","sm"===n.size||"xs"===n.size?"h-1":"h-2",u&&"accent"===n.variant?"bg-neutral":c[n.variant],e),style:{boxShadow:d,...r},children:a})}),h=(0,n.forwardRef)(({className:e,style:a,...r},l)=>{const i=f("Indicator");if(i.isNull||i.clampedFraction<=0)return null;const s="sm"===i.size||"xs"===i.size?4:8;return(0,o.jsx)("div",{ref:l,...r,className:t("h-full rounded-full transition-[width] duration-base ease-out motion-reduce:transition-none",u[i.variant],e),style:{width:`${(100*i.clampedFraction).toFixed(1)}%`,minInlineSize:s,...a}})}),y={Root:v,Label:x,Value:g,Track:w,Indicator:h};export{y as t};