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ACF,OAAO;QAGT,OAAO,GAAG,OAAO;IACnB;IACA,mCAAmC;IACnC,QAAQ,WAAW,GAAG,GAAG,WAAW,IAAI,GAAG,IAAI;IAC/C,OAAO,AAAC,CAAA,GAAA,iBAAS,EAAqB;AACxC;AAGO,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/react-aria/src/collections/Hidden.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {forwardRefType} from '@react-types/shared';\nimport React, {Context, createContext, forwardRef, JSX, ReactElement, ReactNode, useContext} from 'react';\n\n// React doesn't understand the <template> element, which doesn't have children like a normal element.\n// It will throw an error during hydration when it expects the firstChild to contain content rendered\n// on the server, when in reality, the browser will have placed this inside the `content` document fragment.\n// This monkey patches the firstChild property for our special hidden template elements to work around this error.\n// does the same for appendChild/removeChild/insertBefore as per the issue below\n// See https://github.com/facebook/react/issues/19932\nif (typeof HTMLTemplateElement !== 'undefined') {\n  Object.defineProperty(HTMLTemplateElement.prototype, 'firstChild', {\n    configurable: true,\n    enumerable: true,\n    get: function () {\n      return this.content.firstChild;\n    }\n  });\n\n  Object.defineProperty(HTMLTemplateElement.prototype, 'appendChild', {\n    configurable: true,\n    enumerable: true,\n    value: function (node) {\n      return this.content.appendChild(node);\n    }\n  });\n\n  Object.defineProperty(HTMLTemplateElement.prototype, 'removeChild', {\n    configurable: true,\n    enumerable: true,\n    value: function (node) {\n      return this.content.removeChild(node);\n    }\n  });\n\n  Object.defineProperty(HTMLTemplateElement.prototype, 'insertBefore', {\n    configurable: true,\n    enumerable: true,\n    value: function (node, child) {\n      return this.content.insertBefore(node, child);\n    }\n  });\n}\n\nexport const HiddenContext: Context<boolean> = createContext<boolean>(false);\n\nexport function Hidden(props: {children: ReactNode}): JSX.Element {\n  let isHidden = useContext(HiddenContext);\n\n  if (isHidden) {\n    // Don't hide again if we are already hidden.\n    return <>{props.children}</>;\n  }\n\n  let children = (\n    <HiddenContext.Provider value>\n      {props.children}\n    </HiddenContext.Provider>\n  );\n\n  // In SSR, portals are not supported by React. Instead, always render into a <template>\n  // element, which the browser will never display to the user. In addition, the\n  // content is not part of the accessible DOM tree, so it won't affect ids or other accessibility attributes.\n  return <template>{children}</template>;\n}\n\n/** Creates a component that forwards its ref and returns null if it is in a hidden subtree. */\n// Note: this function is handled specially in the documentation generator. If you change it, you'll need to update DocsTransformer as well.\nexport function createHideableComponent<T, P = {}>(fn: (props: P, ref: React.Ref<T>) => ReactElement | null): (props: P & React.RefAttributes<T>) => ReactElement | null {\n  let Wrapper = (props: P, ref: React.Ref<T>) => {\n    let isHidden = useContext(HiddenContext);\n    if (isHidden) {\n      return null;\n    }\n\n    return fn(props, ref);\n  };\n  // @ts-ignore - for react dev tools\n  Wrapper.displayName = fn.displayName || fn.name;\n  return (forwardRef as forwardRefType)(Wrapper);\n}\n\n/** Returns whether the component is in a hidden subtree. */\nexport function useIsHidden(): boolean {\n  return useContext(HiddenContext);\n}\n"],"names":[],"version":3,"file":"Hidden.mjs.map"}