{"version":3,"file":"static/js/8307.df659839.chunk.js","mappings":"yMAEaA,GAAaC,E,SAAAA,GAAU,c,iCCW9BC,GAAiDC,EAAAA,EAAAA,KAAS,SAACC,GAC/D,IAAMC,GAAWC,EAAAA,EAAAA,KACXC,GAAwBC,EAAAA,EAAAA,QAAmC,MAC3DC,GAAyBD,EAAAA,EAAAA,QAA8B,MA2C7D,OAxBAE,EAAAA,EAAAA,YAAU,WAIR,GAAGD,EAAuBE,QAAS,CACjC,IAAIC,EAAcR,EAAMS,SAASD,YAC7BA,IACFH,EAAuBE,QAAQG,UAAYF,EAAYG,QACvDR,EAAsBI,QAAU,IAAIK,EAAAA,EAAoBP,EAAuBE,QAASN,GACrFO,EAAYK,+BACbV,EAAsBI,QAAQO,eAAe,IAAMN,EAAYK,gCA3BnC,WAClC,IAAIE,EAAiBd,EAASe,OAAOC,kBAAkB,gBACvD,GAAIF,EAIJ,GAAGG,EAAAA,MAAAA,WAAiBH,GAClB,IACEA,GAGF,CAFE,MAAOI,GAAM,IAAD,EACZlB,EAASmB,OAAOC,MAAM,oDAAD,OAA+E,QAA/E,EAAqDrB,EAAMS,SAASD,mBAAW,aAA1B,EAA4Bc,KACxG,MAEArB,EAASmB,OAAOG,QAAQ,2DAVxBtB,EAASmB,OAAOI,KAAK,+CAYzB,CAeIC,EACF,CAEA,OAAO,WACFtB,EAAsBI,UACvBJ,EAAsBI,QAAQmB,UAC9BvB,EAAsBI,QAAU,KAEpC,CACF,IAEIP,EAAMS,SAASD,aAKf,SAACZ,EAAU,CAAC+B,UAAW,YAAaC,IAAKvB,IAJpC,IAOX,IAEawB,GAAmBC,EAAAA,EAAAA,GAAahC,EAAe,CAAC,Y","sources":["app-react/components/cms-page/boxes/cms-page.box.tsx","app-react/components/cms-page/cms-page.component.tsx"],"sourcesContent":["import {styledBox} from \"../../../themes/architecture/styled-box\";\n\nexport const CmsPageBox = styledBox(\"CmsPageBox\");","import React, {useEffect, useRef} from 'react';\nimport {observer} from 'mobx-react';\nimport {CmsContentDecorator} from '../../services/cms/cms-content-decorator/cms-content-decorator';\nimport {Check} from '@sparkware/app-utils';\nimport { CmsPageBox } from './boxes/cms-page.box';\nimport {ComponentServicesPick} from \"../../services/component-services-pick\";\nimport {useServices} from \"../../react-hooks/use-services.hook\";\nimport {withServices} from \"../../react-hooks/with-services\";\n\ninterface CmsPageComponentProps extends ComponentServicesPick<'cmsPages'> {\n\n}\n\nconst ComponentBody: React.FC = observer((props) => {\n const services = useServices();\n const _pageContentDecorator = useRef(null);\n const _pageContentElementRef = useRef(null);\n\n const _runB2CContentReadyCallback = () => {\n let contentReadyFn = services.window.getGlobalProperty('contentReady');\n if(!contentReadyFn) {\n services.logger.info(`B2C didn't provide and contentReady callback`);\n return;\n }\n if(Check.isFunction(contentReadyFn)) {\n try {\n contentReadyFn();\n } catch (err) {\n services.logger.error(`Failed to run B2C contentReady callback for page ${props.cmsPages.currentPage?.url}`);\n }\n } else {\n services.logger.warning(`B2C window.contentReady callback is not a function`);\n }\n }\n\n useEffect(() => {\n\n\n\n if(_pageContentElementRef.current) {\n let currentPage = props.cmsPages.currentPage;\n if (currentPage) {\n _pageContentElementRef.current.innerHTML = currentPage.content;\n _pageContentDecorator.current = new CmsContentDecorator(_pageContentElementRef.current, services);\n if(currentPage.elementIdToBeScrolledIntoView) {\n _pageContentDecorator.current.scrollIntoView('#' + currentPage.elementIdToBeScrolledIntoView);\n }\n }\n _runB2CContentReadyCallback();\n }\n\n return () => {\n if(_pageContentDecorator.current) {\n _pageContentDecorator.current.dispose();\n _pageContentDecorator.current = null;\n }\n }\n })\n\n if(!props.cmsPages.currentPage) {\n return null;\n }\n\n return (\n \n );\n\n});\n\nexport const CmsPageComponent = withServices(ComponentBody, ['cmsPages']);"],"names":["CmsPageBox","styledBox","ComponentBody","observer","props","services","useServices","_pageContentDecorator","useRef","_pageContentElementRef","useEffect","current","currentPage","cmsPages","innerHTML","content","CmsContentDecorator","elementIdToBeScrolledIntoView","scrollIntoView","contentReadyFn","window","getGlobalProperty","Check","err","logger","error","url","warning","info","_runB2CContentReadyCallback","dispose","className","ref","CmsPageComponent","withServices"],"sourceRoot":""}