{"version":3,"sources":["app-react/components/cms-page/cms-page.component.tsx"],"names":["CmsPageComponent","observer","_pageContentDecorator","_pageContentElementRef","_capturePageContentElementRef","element","this","_decoratePageContent","reaction","services","cmsPages","currentPage","pageInfo","thisReaction","spinner","stopSpinner","dispose","_disposePageContentDecorator","innerHTML","content","CmsContentDecorator","elementIdToBeScrolledIntoView","scrollIntoView","_runB2CContentReadyCallback","contentReadyFn","window","getGlobalProperty","Check","isFunction","err","logger","error","url","warning","info","className","ref","RoutedComponent"],"mappings":"yPAOaA,EADZC,YACD,8MAEUC,sBAAoD,KAF9D,EAIUC,uBAA6C,KAJvD,EAKUC,8BAAgC,SAACC,GACvC,EAAKF,uBAAyBE,GANlC,uDASE,WAAqB,IAAD,OAClB,0EACAC,KAAKC,uBAELD,KAAKE,UAAS,kBAAM,EAAKC,SAASC,SAASC,eAAa,SAACC,EAAUC,GAC/D,EAAKJ,SAASK,QAAQC,cACtBF,EAAaG,eAfrB,gCAkBE,WACEV,KAAKC,yBAnBT,kCAsBE,WACE,6EACAD,KAAKW,iCAxBT,kCA2BE,WAEE,GADAX,KAAKW,+BACFX,KAAKH,uBAAwB,CAC9B,IAAIQ,EAAcL,KAAKG,SAASC,SAASC,YACrCA,IACFL,KAAKH,uBAAuBe,UAAYP,EAAYQ,QACpDb,KAAKJ,sBAAwB,IAAIkB,IAAoBd,KAAKH,uBAAwBG,KAAKG,UACpFE,EAAYU,+BACbf,KAAKJ,sBAAsBoB,eAAe,IAAMX,EAAYU,gCAGhEf,KAAKiB,iCAtCX,0CA0CE,WACKjB,KAAKJ,wBACNI,KAAKJ,sBAAsBc,UAC3BV,KAAKJ,sBAAwB,QA7CnC,yCAiDE,WACE,IAAIsB,EAAiBlB,KAAKG,SAASgB,OAAOC,kBAAkB,gBAC5D,GAAIF,EAIJ,GAAGG,QAAMC,WAAWJ,GAClB,IACEA,IACA,MAAOK,GAAM,IAAD,EACZvB,KAAKG,SAASqB,OAAOC,MAArB,qEAA+EzB,KAAKG,SAASC,SAASC,mBAAtG,aAA+E,EAAoCqB,WAGrH1B,KAAKG,SAASqB,OAAOG,QAArB,2DAVA3B,KAAKG,SAASqB,OAAOI,KAArB,kDApDN,oBAkEE,WACE,OAAI5B,KAAKG,SAASC,SAASC,YAKzB,qBAAKwB,UAAW,YAAaC,IAAK9B,KAAKF,gCAJhC,SApEb,GAAsCiC,OAAtC","file":"static/js/0.f2fa4e17.chunk.js","sourcesContent":["import React from 'react';\r\nimport {observer} from 'mobx-react';\r\nimport {CmsContentDecorator} from '../../services/cms/cms-content-decorator/cms-content-decorator';\r\nimport {Check} from '@sparkware/app-utils';\r\nimport {RoutedComponent} from '../base-components/routed-component/routed.component';\r\n\r\n@observer\r\nexport class CmsPageComponent extends RoutedComponent<{}> {\r\n\r\n private _pageContentDecorator: CmsContentDecorator | null = null;\r\n\r\n private _pageContentElementRef: HTMLElement | null = null;\r\n private _capturePageContentElementRef = (element: HTMLDivElement | null) => {\r\n this._pageContentElementRef = element;\r\n };\r\n\r\n componentDidMount() {\r\n super.componentDidMount();\r\n this._decoratePageContent();\r\n\r\n this.reaction(() => this.services.cmsPages.currentPage, (pageInfo, thisReaction) => {\r\n this.services.spinner.stopSpinner();\r\n thisReaction.dispose();\r\n });\r\n }\r\n componentDidUpdate() {\r\n this._decoratePageContent();\r\n }\r\n\r\n componentWillUnmount() {\r\n super.componentWillUnmount();\r\n this._disposePageContentDecorator();\r\n }\r\n\r\n private _decoratePageContent() {\r\n this._disposePageContentDecorator();\r\n if(this._pageContentElementRef) {\r\n let currentPage = this.services.cmsPages.currentPage;\r\n if (currentPage) {\r\n this._pageContentElementRef.innerHTML = currentPage.content;\r\n this._pageContentDecorator = new CmsContentDecorator(this._pageContentElementRef, this.services);\r\n if(currentPage.elementIdToBeScrolledIntoView) {\r\n this._pageContentDecorator.scrollIntoView('#' + currentPage.elementIdToBeScrolledIntoView);\r\n }\r\n }\r\n this._runB2CContentReadyCallback();\r\n }\r\n }\r\n\r\n private _disposePageContentDecorator() {\r\n if(this._pageContentDecorator) {\r\n this._pageContentDecorator.dispose();\r\n this._pageContentDecorator = null;\r\n }\r\n }\r\n\r\n private _runB2CContentReadyCallback() {\r\n let contentReadyFn = this.services.window.getGlobalProperty('contentReady');\r\n if(!contentReadyFn) {\r\n this.services.logger.info(`B2C didn't provide and contentReady callback`);\r\n return;\r\n }\r\n if(Check.isFunction(contentReadyFn)) {\r\n try {\r\n contentReadyFn();\r\n } catch (err) {\r\n this.services.logger.error(`Failed to run B2C contentReady callback for page ${this.services.cmsPages.currentPage?.url}`);\r\n }\r\n } else {\r\n this.services.logger.warning(`B2C window.contentReady callback is not a function`);\r\n }\r\n }\r\n\r\n render() {\r\n if(!this.services.cmsPages.currentPage) {\r\n return null;\r\n }\r\n\r\n return (\r\n
\r\n );\r\n }\r\n}\r\n"],"sourceRoot":""}