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OAAO,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAAc;gBAC3F,QAAQ,IAAI,CAAC,CAAC,sCAAsC,EAAE,UAAU,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAChF,UAAU,OAAO,GAAG;YACtB;QACF;IACF,GAAG;QAAC;QAAW;QAAQ;KAAU;IAEjC,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAC7B,GAAG,UAAU;QACb,GAAG,kBAAkB;QACtB,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK;OACJ;AAGP;AAMO,SAAS;IACd,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;IAC/B,IAAI,CAAC,SACH,MAAM,IAAI,MACR;IAIJ,OAAO;AACT;AAEO,SAAS,0CAAoB,KAAQ;IAC1C,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;IAC/B,IAAI,CAAC,SACH,OAAO;IAET,OAAO,OAAO,MAAM,CAClB,CAAC,GACD;QACE,SAAS,QAAQ,OAAO;QACxB,cAAc,QAAQ,YAAY;QAClC,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,iBAAiB,QAAQ,eAAe;IAC1C,GACA;AAEJ","sources":["packages/@adobe/react-spectrum/src/provider/Provider.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 {BreakpointProvider, useMatchedBreakpoints} from '../utils/BreakpointProvider';\n\nimport clsx from 'clsx';\nimport {Context} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {I18nProvider, useLocale} from 'react-aria/I18nProvider';\nimport {ModalProvider, useModalProvider} from 'react-aria/private/overlays/useModal';\nimport {ProviderContext, ProviderProps} from './types';\nimport React, {useContext, useEffect, useRef} from 'react';\nimport {RouterProvider} from 'react-aria/private/utils/openLink';\nimport {shouldKeepSpectrumClassNames} from '../utils/classNames';\nimport styles from '@adobe/spectrum-css-temp/components/page/vars.css';\nimport typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';\nimport {useColorScheme, useScale} from './mediaQueries';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useStyleProps} from '../utils/styleProps';\n// @ts-ignore\nimport {version} from '../../package.json';\n\nconst DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};\n\n/**\n * Provider is the container for all React Spectrum applications.\n * It defines the theme, locale, and other application level settings,\n * and can also be used to provide common properties to a group of components.\n */\nexport const Provider = React.forwardRef(function Provider(\n  props: ProviderProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let prevContext = useContext(Context);\n  let prevColorScheme = prevContext && prevContext.colorScheme;\n  let prevBreakpoints = prevContext && prevContext.breakpoints;\n  let {theme = prevContext && prevContext.theme, defaultColorScheme} = props;\n  if (!theme) {\n    throw new Error('theme not found, the parent provider must have a theme provided');\n  }\n  // Hooks must always be called.\n  let autoColorScheme = useColorScheme(theme, defaultColorScheme || 'light');\n  let autoScale = useScale(theme);\n  let {locale: prevLocale} = useLocale();\n  // if the new theme doesn't support the prevColorScheme, we must resort to the auto\n  let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;\n\n  // importance of color scheme props > parent > auto:(OS > default > omitted)\n  let {\n    colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,\n    scale = prevContext ? prevContext.scale : autoScale,\n    locale = prevContext ? prevLocale : undefined,\n    breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,\n    children,\n    isQuiet,\n    isEmphasized,\n    isDisabled,\n    isRequired,\n    isReadOnly,\n    validationState,\n    router,\n    ...otherProps\n  } = props;\n\n  // select only the props with values so undefined props don't overwrite prevContext values\n  let currentProps = {\n    version,\n    theme,\n    breakpoints,\n    colorScheme,\n    scale,\n    isQuiet,\n    isEmphasized,\n    isDisabled,\n    isRequired,\n    isReadOnly,\n    validationState\n  };\n\n  let matchedBreakpoints = useMatchedBreakpoints(breakpoints!);\n  let filteredProps = {};\n  Object.entries(currentProps).forEach(\n    ([key, value]) => value !== undefined && (filteredProps[key] = value)\n  );\n\n  // Merge options with parent provider\n  let context = Object.assign({}, prevContext, filteredProps);\n\n  // Only wrap in a DOM node if the theme, colorScheme, or scale changed\n  let contents = children;\n  let domProps = filterDOMProps(otherProps);\n  let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});\n  if (\n    !prevContext ||\n    props.locale ||\n    theme !== prevContext.theme ||\n    colorScheme !== prevContext.colorScheme ||\n    scale !== prevContext.scale ||\n    Object.keys(domProps).length > 0 ||\n    otherProps.UNSAFE_className ||\n    (styleProps.style && Object.keys(styleProps.style).length > 0)\n  ) {\n    contents = (\n      <ProviderWrapper\n        {...props}\n        UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}}\n        ref={ref}>\n        {contents}\n      </ProviderWrapper>\n    );\n  }\n\n  if (router) {\n    contents = <RouterProvider {...router}>{contents}</RouterProvider>;\n  }\n\n  return (\n    <Context.Provider value={context}>\n      <I18nProvider locale={locale}>\n        <BreakpointProvider matchedBreakpoints={matchedBreakpoints}>\n          <ModalProvider>{contents}</ModalProvider>\n        </BreakpointProvider>\n      </I18nProvider>\n    </Context.Provider>\n  );\n});\n\nconst ProviderWrapper = React.forwardRef(function ProviderWrapper(\n  props: ProviderProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {children, ...otherProps} = props;\n  let {locale, direction} = useLocale();\n  let {theme, colorScheme, scale} = useProvider();\n  let {modalProviderProps} = useModalProvider();\n  let {styleProps} = useStyleProps(otherProps);\n  let domRef = useDOMRef(ref);\n\n  let themeKey = Object.keys(theme[colorScheme]!)[0];\n  let scaleKey = Object.keys(theme[scale]!)[0];\n\n  let className = clsx(\n    styleProps.className,\n    styles['spectrum'],\n    typographyStyles['spectrum'],\n    Object.values(theme[colorScheme]!),\n    Object.values(theme[scale]!),\n    theme.global ? Object.values(theme.global) : null,\n    {\n      'react-spectrum-provider': shouldKeepSpectrumClassNames,\n      spectrum: shouldKeepSpectrumClassNames,\n      [themeKey]: shouldKeepSpectrumClassNames,\n      [scaleKey]: shouldKeepSpectrumClassNames\n    }\n  );\n\n  let style = {\n    ...styleProps.style,\n    // This ensures that browser native UI like scrollbars are rendered in the right color scheme.\n    // See https://web.dev/color-scheme/.\n    colorScheme:\n      props.colorScheme ??\n      colorScheme ??\n      Object.keys(theme)\n        .filter(k => k === 'light' || k === 'dark')\n        .join(' ')\n  };\n\n  let hasWarned = useRef(false);\n  useEffect(() => {\n    if (direction && domRef.current) {\n      let closestDir = domRef.current?.parentElement?.closest('[dir]');\n      let dir = closestDir && closestDir.getAttribute('dir');\n      if (dir && dir !== direction && !hasWarned.current && process.env.NODE_ENV !== 'production') {\n        console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);\n        hasWarned.current = true;\n      }\n    }\n  }, [direction, domRef, hasWarned]);\n\n  return (\n    <div\n      {...filterDOMProps(otherProps)}\n      {...styleProps}\n      {...modalProviderProps}\n      className={className}\n      style={style}\n      lang={locale}\n      dir={direction}\n      ref={domRef}>\n      {children}\n    </div>\n  );\n});\n\n/**\n * Returns the various settings and styles applied by the nearest parent Provider. Properties\n * explicitly set by the nearest parent Provider override those provided by preceeding Providers.\n */\nexport function useProvider(): ProviderContext {\n  let context = useContext(Context);\n  if (!context) {\n    throw new Error(\n      'No root provider found, please make sure your app is wrapped within a <Provider>. ' +\n        'Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.'\n    );\n  }\n  return context;\n}\n\nexport function useProviderProps<T>(props: T): T {\n  let context = useContext(Context);\n  if (!context) {\n    return props;\n  }\n  return Object.assign(\n    {},\n    {\n      isQuiet: context.isQuiet,\n      isEmphasized: context.isEmphasized,\n      isDisabled: context.isDisabled,\n      isRequired: context.isRequired,\n      isReadOnly: context.isReadOnly,\n      validationState: context.validationState\n    },\n    props\n  );\n}\n"],"names":[],"version":3,"file":"Provider.mjs.map"}