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EAAE,UAAU,CAAC,CAAC;sBAE5B,gCAAC;QACC,WAAW,CAAA,GAAA,yCAAS,EAAE,CAAA,GAAA,uDAAU,GAAG;QACnC,GAAE;QACF,MAAM;sBAER,gCAAC;QACC,WAAW,CAAA,GAAA,yCAAS,EAAE,CAAA,GAAA,uDAAU,GAAG;QACnC,GAAE;;AAIV","sources":["packages/@adobe/react-spectrum/src/color/ColorThumb.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {classNames} from '../utils/classNames';\n\nimport {Color} from 'react-stately/Color';\nimport {DOMProps, RefObject} from '@react-types/shared';\nimport {Overlay} from '../overlays/Overlay';\nimport React, {CSSProperties, JSX, ReactElement, useRef, useState} from 'react';\nimport stylesHandle from '@adobe/spectrum-css-temp/components/colorhandle/vars.css';\nimport stylesLoupe from '@adobe/spectrum-css-temp/components/colorloupe/vars.css';\nimport {useId} from 'react-aria/useId';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useProvider} from '../provider/Provider';\n\ninterface ColorThumbProps extends DOMProps {\n  value: Color;\n  isDisabled?: boolean;\n  isDragging?: boolean; // shows the color loupe\n  isFocused?: boolean; // makes the circle larger\n  className?: string;\n  children?: ReactElement;\n  style?: CSSProperties;\n  containerRef?: RefObject<HTMLElement | null>;\n}\n\nfunction ColorThumb(props: ColorThumbProps): JSX.Element {\n  let {\n    value,\n    isDisabled,\n    isDragging,\n    isFocused,\n    children,\n    className = '',\n    style,\n    containerRef,\n    ...otherProps\n  } = props;\n\n  let valueCSS = value.toString('css');\n  let loupeRef = useRef<HTMLElement | null>(null);\n  let provider = useProvider();\n\n  return (\n    <div\n      className={\n        classNames(stylesHandle, 'spectrum-ColorHandle', {\n          'is-focused': isFocused,\n          'is-disabled': isDisabled\n        }) +\n        ' ' +\n        className\n      }\n      style={style}\n      {...otherProps}>\n      <div\n        className={classNames(stylesHandle, 'spectrum-ColorHandle-color')}\n        style={{backgroundColor: valueCSS}}\n      />\n      <Overlay isOpen={isDragging && provider != null} nodeRef={loupeRef}>\n        <ColorLoupe\n          valueCSS={valueCSS}\n          containerRef={containerRef}\n          loupeRef={loupeRef}\n          style={style}\n        />\n      </Overlay>\n      {children}\n    </div>\n  );\n}\n\n// ColorLoupe is rendered in a portal so that it breaks out of clipped/scrolling containers (e.g. popovers).\nfunction ColorLoupe({isOpen, valueCSS, containerRef, loupeRef, style}: any) {\n  let patternId = useId();\n\n  // Get the bounding rectangle of the container (e.g. ColorArea/ColorSlider).\n  let [containerRect, setContainerRect] = useState({top: 0, left: 0, width: 0, height: 0});\n  useLayoutEffect(() => {\n    let rect = containerRef.current?.getBoundingClientRect();\n    setContainerRect({\n      top: rect?.top || 0,\n      left: rect?.left || 0,\n      width: rect?.width || 0,\n      height: rect?.height || 0\n    });\n  }, [containerRef]);\n\n  // Compute the pixel position of the thumb.\n  let thumbTop = style.top || '50%';\n  if (typeof thumbTop === 'string' && thumbTop.endsWith('%')) {\n    thumbTop = (parseFloat(style.top || '50%') / 100) * containerRect.height;\n  } else if (typeof thumbTop === 'string' && thumbTop.endsWith('px')) {\n    thumbTop = parseFloat(thumbTop);\n  }\n\n  let thumbLeft = style.left || '50%';\n  if (typeof thumbLeft === 'string' && thumbLeft.endsWith('%')) {\n    thumbLeft = (parseFloat(thumbLeft || '50%') / 100) * containerRect.width;\n  } else if (typeof thumbLeft === 'string' && thumbLeft.endsWith('px')) {\n    thumbLeft = parseFloat(thumbLeft);\n  }\n\n  return (\n    <svg\n      className={classNames(stylesLoupe, 'spectrum-ColorLoupe', {'is-open': isOpen})}\n      style={{\n        // Position relative to the viewport.\n        position: 'fixed',\n        top: containerRect.top + thumbTop,\n        left: containerRect.left + thumbLeft\n      }}\n      ref={loupeRef}\n      aria-hidden=\"true\">\n      <pattern id={patternId} x=\"0\" y=\"0\" width=\"16\" height=\"16\" patternUnits=\"userSpaceOnUse\">\n        <rect\n          className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-background')}\n          x=\"0\"\n          y=\"0\"\n          width=\"16\"\n          height=\"16\"\n        />\n        <rect\n          className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')}\n          x=\"0\"\n          y=\"0\"\n          width=\"8\"\n          height=\"8\"\n        />\n        <rect\n          className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner-checker')}\n          x=\"8\"\n          y=\"8\"\n          width=\"8\"\n          height=\"8\"\n        />\n      </pattern>\n      <path\n        className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n        d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n        fill={`url(#${patternId})`}\n      />\n      <path\n        className={classNames(stylesLoupe, 'spectrum-ColorLoupe-inner')}\n        d=\"M25 1a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n        fill={valueCSS}\n      />\n      <path\n        className={classNames(stylesLoupe, 'spectrum-ColorLoupe-outer')}\n        d=\"M25 3A21.98 21.98 0 003 25c0 6.2 4 14.794 11.568 24.853A144.233 144.233 0 0025 62.132a144.085 144.085 0 0010.4-12.239C42.99 39.816 47 31.209 47 25A21.98 21.98 0 0025 3m0-2a24 24 0 0124 24c0 16.255-24 40-24 40S1 41.255 1 25A24 24 0 0125 1z\"\n      />\n    </svg>\n  );\n}\n\nexport {ColorThumb};\n"],"names":[],"version":3,"file":"ColorThumb.mjs.map"}