{"version":3,"sources":["webpack://gatsby-starter-hello-world/../src/components/lazy-hydrate.tsx"],"names":["lazyHydrate","root","hydrated","forceHydrate","image","loading","isLoading","isLoaded","toggleIsLoaded","ref","imgClassName","imgStyle","objectPosition","backgroundColor","objectFit","props","width","height","layout","images","placeholder","wrapperBackgroundColor","cacheKey","JSON","stringify","component","React","LayoutWrapper","Placeholder","getPlaceholderProps","MainImage","className","getMainProps","current","ReactDOM","render"],"mappings":"wYAgBgBA,IAedC,EACAC,EACAC,OAfEC,UACAC,YACAC,cACAC,aACAC,mBACAC,QACAC,qBACAC,sBAAW,KACXC,mBACAC,wBACAC,iCACGC,eAOHC,EAMEZ,EANFY,MACAC,EAKEb,EALFa,OACAC,EAIEd,EAJFc,OACAC,EAGEf,EAHFe,OACAC,EAEEhB,EAFFgB,YACiBC,EACfjB,EADFS,gBAGIS,EAAWC,KAAKC,UAAUL,GAEhCR,WACEG,YACAF,iBACAC,mBACGF,GAGL,IAAMc,EACJC,gBAACC,KAAcT,OAAQA,EAAQF,MAAOA,EAAOC,OAAQA,GACnDS,gBAACE,gBACKC,OACFT,EACAb,EACAW,EACAF,EACAC,EACAI,EACAP,EACAF,KAIJc,gBAACI,eACMf,GACLC,MAAOA,EACPC,OAAQA,EACRc,UAAWrB,IACPsB,OACF1B,EACAC,EACAY,EACAd,EACAG,EACAc,EACAb,EACAE,MA2BR,OArBIV,EAAKgC,UAGHC,cACGhC,EAAS+B,UAEZ/B,EAAS+B,QAAUC,aAAoBjC,EAAKgC,UAI9C/B,EAAS+B,QAAQE,OAAOV,MAGtBvB,EAAS+B,SAAW9B,EAAa8B,QAC7BC,SACAA,WACGT,EAAWxB,EAAKgC,SACzB/B,EAAS+B,aAAU,WAKjBhC,EAAKgC,UAEHC,aAEFhC,EAAS+B,QAAQE,OAAO,MAExBD,SAAgB,KAAiCjC,EAAKgC","file":"987-958786ccd0703b3e7625.js","sourcesContent":["import React, { MutableRefObject } from \"react\"\nimport ReactDOM from \"react-dom\"\nimport { GatsbyImageProps } from \"./gatsby-image.browser\"\nimport { LayoutWrapper } from \"./layout-wrapper\"\nimport { Placeholder } from \"./placeholder\"\nimport { MainImageProps, MainImage } from \"./main-image\"\nimport { getMainProps, getPlaceholderProps } from \"./hooks\"\nimport { ReactElement } from \"react\"\n\ntype LazyHydrateProps = Omit & {\n isLoading: boolean\n isLoaded: boolean // alwaystype SetStateAction = S | ((prevState: S) => S);\n toggleIsLoaded: (toggle: boolean) => void\n ref: MutableRefObject\n}\n\nexport function lazyHydrate(\n {\n image,\n loading,\n isLoading,\n isLoaded,\n toggleIsLoaded,\n ref,\n imgClassName,\n imgStyle = {},\n objectPosition,\n backgroundColor,\n objectFit = `cover`,\n ...props\n }: LazyHydrateProps,\n root: MutableRefObject,\n hydrated: MutableRefObject,\n forceHydrate: MutableRefObject\n): (() => void) | null {\n const {\n width,\n height,\n layout,\n images,\n placeholder,\n backgroundColor: wrapperBackgroundColor,\n } = image\n\n const cacheKey = JSON.stringify(images)\n\n imgStyle = {\n objectFit,\n objectPosition,\n backgroundColor,\n ...imgStyle,\n }\n\n const component = (\n \n \n\n )}\n width={width}\n height={height}\n className={imgClassName}\n {...getMainProps(\n isLoading,\n isLoaded,\n images,\n loading,\n toggleIsLoaded,\n cacheKey,\n ref,\n imgStyle\n )}\n />\n \n )\n\n if (root.current) {\n // Force render to mitigate \"Expected server HTML to contain a matching\" in develop\n // @ts-ignore react 18 typings\n if (ReactDOM.createRoot) {\n if (!hydrated.current) {\n // @ts-ignore react 18 typings\n hydrated.current = ReactDOM.createRoot(root.current)\n }\n\n // @ts-ignore react 18 typings\n hydrated.current.render(component)\n } else {\n const doRender =\n hydrated.current || forceHydrate.current\n ? ReactDOM.render\n : ReactDOM.hydrate\n doRender(component, root.current)\n hydrated.current = true\n }\n }\n\n return (): void => {\n if (root.current) {\n // @ts-ignore react 18 typings\n if (ReactDOM.createRoot) {\n // @ts-ignore react 18 typings\n hydrated.current.render(null)\n } else {\n ReactDOM.render(null as unknown as ReactElement, root.current)\n }\n }\n }\n}\n"],"sourceRoot":""}