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EAAKrE,KAAKgD,SAAS/B,cAAcmD,GAClCC,GACDA,EAAGlD,gBAIP,CAFE,MAAOwB,GACP3C,KAAKiD,SAASqB,OAAOT,MAAM,8CAAD,OAA+CO,GAAwBzB,EACnG,CAEF,KAAC,EAjD6B,E","sources":["app-react/services/cms/cms-content-decorator/cms-link.ts","app-react/services/cms/cms-content-decorator/evaluate-scripts.ts","app-react/services/cms/cms-content-decorator/cms-content-decorator.ts"],"sourcesContent":["import {IServiceFactory} from '../../service-factory.interface';\n\nexport class CmsLink {\n constructor(private _anchorElement: HTMLAnchorElement, private _cmsContentRootElement: HTMLElement, private _services: IServiceFactory) {\n this._clickHandler = this._clickHandler.bind(this);\n this._anchorElement.addEventListener('click', this._clickHandler);\n }\n\n private _clickHandler(event) {\n event.preventDefault();\n let anchorUri = this._services.location.tryParseUrl(this._anchorElement.href);\n let currentUri = this._services.location.currentUri;\n\n if(currentUri.origin === anchorUri.origin\n && currentUri.pathName.equals(anchorUri.pathName)\n && !anchorUri.hash.isEmpty) { // if the anchor href refers to the current route and there is a hash in the anchor href then we need to scroll into view an element with id = #hash\n let element = this._cmsContentRootElement.querySelector(anchorUri.hash.toString());\n if(element) {\n element.scrollIntoView();\n }\n } else {\n this._services.location.push(this._anchorElement.href);\n }\n };\n\n\n dispose() {\n this._anchorElement.removeEventListener('click', this._clickHandler);\n }\n\n}\n","/**\n * @desc We need this to evaluate all the scripts that b2c add to the components banners and pages\n * @param html\n * @return {any}\n * @private\n */\nimport {isOrbitInQAMode} from '../../../../utils/qa-mode-utils';\nimport {isInsideAutomation} from '../../../../utils/automation-helpers';\n\nexport function evaluateScripts(html: string): void {\n\n if(!html) {\n return;\n }\n\n /**\n Webpack dev server returns the public/index.html instead of 404 for calls like api/pagecontent.\n When this happens this function basically will execute the script in the public/index.html.\n And that script is launcher.min.js. So basically we will try to load again orbit and sdk and this will fail.\n */\n if (0 <= html.indexOf('')) {\n return;\n }\n\n let scriptRegex = /]*>([\\s\\S]*?)<\\/script>/gm;\n\n // Remove comment from the html(so we don't run scripts in comment),\n html = html.replace(//g, \"\");\n let match = scriptRegex.exec(html);\n\n while (match) {\n try {\n evaluateScriptsWithExternalFile(match[0]);\n match = scriptRegex.exec(html);\n } catch (err) {\n if(!isInsideAutomation()) {\n console.error('Failed to load script!', match, err);\n }\n\n }\n }\n}\n\n/**\n * Evaluate scripts with external file. ex: \n */\nfunction evaluateScriptsWithExternalFile(html: string) {\n try {\n const fakeDiv = document.createElement('div');\n fakeDiv.innerHTML = html.trim();\n\n const scriptElements = fakeDiv.getElementsByTagName('script');\n const elementsLength = scriptElements ? scriptElements.length : 0;\n\n for (let index = 0; index < elementsLength; index++) {\n const script = document.createElement(\"script\");\n\n if (scriptElements[index]['src']) {\n script.src = scriptElements[index]['src'];\n } else {\n //Add try catch to B2C scripts\n const tryStart = \"try{\";\n const consoleLogFunc = (isOrbitInQAMode() ? 'warn' : 'error');\n const tryEnd = `}catch(e){console.${consoleLogFunc}('B2C ERROR In EXTERNAL SCRIPT, ERROR MESSAGE: ', e)}`;\n\n script.innerHTML = tryStart + scriptElements[index]['innerHTML'] + tryEnd;\n\n }\n\n document.head.appendChild(script).parentNode?.removeChild(script);\n }\n } catch (err) {\n if(!isInsideAutomation()) {\n console.log('Error in evaluateScriptsWithExternalFile function, err message:', err);\n }\n\n }\n}\n","import {IServiceFactory} from '../../service-factory.interface';\nimport {CmsLink} from './cms-link';\nimport {Check} from '@sparkware/app-utils';\nimport {evaluateScripts} from \"./evaluate-scripts\";\n\nexport class CmsContentDecorator {\n constructor(private _element: HTMLElement, private services: IServiceFactory ) {\n this._evaluateScripts();\n this._loadCmsLinks();\n }\n\n private _cmsLinks: CmsLink[] = [];\n\n\n dispose() {\n this._cmsLinks.forEach(a => a.dispose());\n }\n\n\n private _evaluateScripts() {\n evaluateScripts(this._element.innerHTML);\n }\n\n\n private _loadCmsLinks() {\n let linkTags = this._element.getElementsByTagName('a');\n for(let i = 0; i < linkTags.length; i++) {\n let currentLink = linkTags[i] as HTMLAnchorElement;\n if (Check.isEmpty(currentLink.href) || currentLink.target === '_blank') {\n continue;\n }\n\n let anchorUri = this.services.location.tryParseUrl(currentLink.href);\n if(!anchorUri) {\n continue;\n }\n\n if(anchorUri.origin === this.services.location.currentUri.origin) {\n this._cmsLinks.push(new CmsLink(currentLink, this._element, this.services));\n }\n\n }\n }\n\n scrollIntoView(childElementSelector: string): void {\n try {\n let el = this._element.querySelector(childElementSelector);\n if(el) {\n el.scrollIntoView();\n }\n } catch (err) {\n this.services.logger.error(`Failed to scroll into view element with id ${childElementSelector}`, err);\n }\n\n }\n}\n"],"names":["CmsLink","_anchorElement","_cmsContentRootElement","_services","this","_clickHandler","bind","addEventListener","event","preventDefault","anchorUri","location","tryParseUrl","href","currentUri","origin","pathName","equals","hash","isEmpty","element","querySelector","toString","scrollIntoView","push","removeEventListener","evaluateScriptsWithExternalFile","html","fakeDiv","document","createElement","innerHTML","trim","scriptElements","getElementsByTagName","elementsLength","length","index","script","src","consoleLogFunc","isOrbitInQAMode","tryEnd","head","appendChild","parentNode","removeChild","err","isInsideAutomation","console","log","CmsContentDecorator","_element","services","_cmsLinks","_evaluateScripts","_loadCmsLinks","forEach","a","dispose","indexOf","scriptRegex","replace","match","exec","error","evaluateScripts","linkTags","i","currentLink","Check","target","childElementSelector","el","logger"],"sourceRoot":""}