{"version":3,"sources":["app-react/components/cms-page/cms-page.component.tsx"],"names":["CmsPageComponent","observer","_pageContentDecorator","_pageContentElementRef","_capturePageContentElementRef","element","this","_decoratePageContent","_disposePageContentDecorator","currentPage","services","cmsPages","innerHTML","content","CmsContentDecorator","elementIdToBeScrolledIntoView","scrollIntoView","_runB2CContentReadyCallback","dispose","contentReadyFn","window","getGlobalProperty","Check","isFunction","err","logger","error","url","warning","info","className","ref","RoutedComponent"],"mappings":"kQAOaA,EADZC,YACD,8MAEUC,sBAAoD,KAF9D,EAIUC,uBAA6C,KAJvD,EAKUC,8BAAgC,SAACC,GACvC,EAAKF,uBAAyBE,GANlC,uDASE,WACE,0EACAC,KAAKC,yBAXT,gCAcE,WACED,KAAKC,yBAfT,kCAkBE,WACE,6EACAD,KAAKE,iCApBT,kCAuBE,WAEE,GADAF,KAAKE,+BACFF,KAAKH,uBAAwB,CAC9B,IAAIM,EAAcH,KAAKI,SAASC,SAASF,YACrCA,IACFH,KAAKH,uBAAuBS,UAAYH,EAAYI,QACpDP,KAAKJ,sBAAwB,IAAIY,IAAoBR,KAAKH,uBAAwBG,KAAKI,UACpFD,EAAYM,+BACbT,KAAKJ,sBAAsBc,eAAe,IAAMP,EAAYM,gCAGhET,KAAKW,iCAlCX,0CAsCE,WACKX,KAAKJ,wBACNI,KAAKJ,sBAAsBgB,UAC3BZ,KAAKJ,sBAAwB,QAzCnC,yCA6CE,WACE,IAAIiB,EAAiBb,KAAKI,SAASU,OAAOC,kBAAkB,gBAC5D,GAAIF,EAIJ,GAAGG,QAAMC,WAAWJ,GAClB,IACEA,IACA,MAAOK,GAAM,IAAD,EACZlB,KAAKI,SAASe,OAAOC,MAArB,qEAA+EpB,KAAKI,SAASC,SAASF,mBAAtG,aAA+E,EAAoCkB,WAGrHrB,KAAKI,SAASe,OAAOG,QAArB,2DAVAtB,KAAKI,SAASe,OAAOI,KAArB,kDAhDN,oBA8DE,WACE,OAAIvB,KAAKI,SAASC,SAASF,YAKzB,qBAAKqB,UAAW,YAAaC,IAAKzB,KAAKF,gCAJhC,SAhEb,GAAsC4B,OAAtC","file":"static/js/24.21749c57.chunk.js","sourcesContent":["import React 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 {RoutedComponent} from '../base-components/routed-component/routed.component';\n\n@observer\nexport class CmsPageComponent extends RoutedComponent<{}> {\n\n private _pageContentDecorator: CmsContentDecorator | null = null;\n\n private _pageContentElementRef: HTMLElement | null = null;\n private _capturePageContentElementRef = (element: HTMLDivElement | null) => {\n this._pageContentElementRef = element;\n };\n\n componentDidMount() {\n super.componentDidMount();\n this._decoratePageContent();\n }\n \n componentDidUpdate() {\n this._decoratePageContent();\n }\n\n componentWillUnmount() {\n super.componentWillUnmount();\n this._disposePageContentDecorator();\n }\n\n private _decoratePageContent() {\n this._disposePageContentDecorator();\n if(this._pageContentElementRef) {\n let currentPage = this.services.cmsPages.currentPage;\n if (currentPage) {\n this._pageContentElementRef.innerHTML = currentPage.content;\n this._pageContentDecorator = new CmsContentDecorator(this._pageContentElementRef, this.services);\n if(currentPage.elementIdToBeScrolledIntoView) {\n this._pageContentDecorator.scrollIntoView('#' + currentPage.elementIdToBeScrolledIntoView);\n }\n }\n this._runB2CContentReadyCallback();\n }\n }\n\n private _disposePageContentDecorator() {\n if(this._pageContentDecorator) {\n this._pageContentDecorator.dispose();\n this._pageContentDecorator = null;\n }\n }\n\n private _runB2CContentReadyCallback() {\n let contentReadyFn = this.services.window.getGlobalProperty('contentReady');\n if(!contentReadyFn) {\n this.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 this.services.logger.error(`Failed to run B2C contentReady callback for page ${this.services.cmsPages.currentPage?.url}`);\n }\n } else {\n this.services.logger.warning(`B2C window.contentReady callback is not a function`);\n }\n }\n\n render() {\n if(!this.services.cmsPages.currentPage) {\n return null;\n }\n\n return (\n
\n );\n }\n}\n"],"sourceRoot":""}