{"version":3,"file":"Portal.js","names":[],"sources":["esm/Portal.js"],"sourcesContent":["\nimport { TamaguiRoot, Theme, useDidFinishSSR, usePortalThemeState } from \"@tamagui/web\";\nimport { useStackedZIndex, ZIndexHardcodedContext } from \"@tamagui/z-index-stack\";\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getStackedZIndexProps } from \"./helpers\";\nimport { jsx } from \"react/jsx-runtime\";\nconst Portal = React.memo((propsIn) => {\n  const { children, passThrough, style, open, hidden } = propsIn;\n  const { name: themeName, layers: themeLayers } = usePortalThemeState();\n  const didHydrate = useDidFinishSSR();\n  const zIndex = useStackedZIndex(getStackedZIndexProps(propsIn));\n  if (passThrough) {\n    return children;\n  }\n  if (!didHydrate) {\n    return null;\n  }\n  return createPortal(\n    /* @__PURE__ */ jsx(\n      TamaguiRoot,\n      {\n        theme: themeName,\n        style: {\n          zIndex,\n          position: \"fixed\",\n          inset: 0,\n          contain: \"strict\",\n          pointerEvents: open ? \"auto\" : \"none\",\n          // ios 26 safari colors the status-bar strip by hit-testing the top edge\n          // of the viewport: a full-viewport fixed host whose children are all\n          // invisible (opacity 0) samples as a solid white bar. visibility:hidden\n          // boxes are never hit-tested, and unlike display:none they keep layout,\n          // so closed-but-mounted content can still be measured. consumers pass\n          // hidden while closed AND not animating out (a childless host is\n          // already exempt from sampling, so default undefined is fine).\n          visibility: hidden ? \"hidden\" : void 0,\n          // prevent mobile browser from scrolling/moving this fixed element\n          touchAction: \"none\",\n          display: \"flex\",\n          ...style\n        },\n        children: themeLayers.reduceRight(\n          (node, layer, index) => /* @__PURE__ */ jsx(Theme, { forceClassName: true, _themeUpdate: layer, children: node }, index),\n          // provide computed z-index to children so nested portals can stack above\n          /* @__PURE__ */ jsx(ZIndexHardcodedContext.Provider, { value: zIndex, children })\n        )\n      }\n    ),\n    globalThis.document?.body\n  );\n});\nexport {\n  Portal\n};\n//# sourceMappingURL=Portal.js.map\n"],"mappings":";;;;;;;;AAOA,MAAM,SAAS,MAAM,MAAM,YAAY;CACrC,MAAM,EAAE,UAAU,aAAa,OAAO,MAAM,WAAW;CACvD,MAAM,EAAE,MAAM,WAAW,QAAQ,gBAAgB,oBAAoB;CACrE,MAAM,aAAa,gBAAgB;CACnC,MAAM,SAAS,iBAAiB,sBAAsB,OAAO,CAAC;CAC9D,IAAI,aAAa;EACf,OAAO;CACT;CACA,IAAI,CAAC,YAAY;EACf,OAAO;CACT;CACA,OAAO,aACW,oBACd,aACA;EACE,OAAO;EACP,OAAO;GACL;GACA,UAAU;GACV,OAAO;GACP,SAAS;GACT,eAAe,OAAO,SAAS;GAQ/B,YAAY,SAAS,WAAW,KAAK;GAErC,aAAa;GACb,SAAS;GACT,GAAG;EACL;EACA,UAAU,YAAY,aACnB,MAAM,OAAO,UAA0B,oBAAI,OAAO;GAAE,gBAAgB;GAAM,cAAc;GAAO,UAAU;EAAK,GAAG,KAAK,GAEvG,oBAAI,uBAAuB,UAAU;GAAE,OAAO;GAAQ;EAAS,CAAC,CAClF;CACF,CACF,GACA,WAAW,UAAU,IACvB;AACF,CAAC"}