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copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaMeterProps, useMeter} from 'react-aria/useMeter';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface MeterProps extends Omit<AriaMeterProps, 'label'>, RenderProps<MeterRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-Meter'\n   */\n  className?: ClassNameOrFunction<MeterRenderProps>\n}\n\nexport interface MeterRenderProps {\n  /**\n   * The value as a percentage between the minimum and maximum.\n   */\n  percentage: number,\n  /**\n   * A formatted version of the value.\n   * @selector [aria-valuetext]\n   */\n  valueText: string | undefined\n}\n\nexport const MeterContext = createContext<ContextValue<MeterProps, HTMLDivElement>>(null);\n\n/**\n * A meter represents a quantity within a known range, or a fractional value.\n */\nexport const Meter = /*#__PURE__*/ (forwardRef as forwardRefType)(function Meter(props: MeterProps, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, MeterContext);\n  let {\n    value = 0,\n    minValue = 0,\n    maxValue = 100\n  } = props;\n  value = clamp(value, minValue, maxValue);\n\n  let [labelRef, label] = useSlot(\n    !props['aria-label'] && !props['aria-labelledby']\n  );\n  let {\n    meterProps,\n    labelProps\n  } = useMeter({...props, label});\n\n  // Calculate the width of the progress bar as a percentage\n  let percentage = (value - minValue) / (maxValue - minValue) * 100;\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-Meter',\n    values: {\n      percentage,\n      valueText: meterProps['aria-valuetext']\n    }\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <dom.div {...mergeProps(DOMProps, renderProps, meterProps)} ref={ref} slot={props.slot || undefined}>\n      <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n        {renderProps.children}\n      </LabelContext.Provider>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"Meter.cjs.map"}