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/unbxd-recommendations/unbxd-recommendations.tsx?b884","webpack://henrys-ecommerce/./src/modules/unbxd-recommendations/unbxd-recommendations.view.tsx?9ff7","webpack://henrys-ecommerce/./lib/unbxd-recommendations/module-registration.js?334f","webpack://henrys-ecommerce/external var \"React\"?0d3b","webpack://henrys-ecommerce/external var \"ReactDOM\"?853b"],"sourcesContent":["/*!\r\n * Copyright (c) Microsoft Corporation.\r\n * All rights reserved. See LICENSE in the project root for license information.\r\n */\r\n\r\nimport * as React from 'react';\r\n\r\nimport { IUnbxdRecommendationsData } from './unbxd-recommendations.data';\r\nimport { IUnbxdRecommendationsProps } from './unbxd-recommendations.props.autogenerated';\r\n\r\nexport interface IUnbxdRecommendationsViewProps extends IUnbxdRecommendationsProps {}\r\n\r\n/**\r\n *\r\n * UnbxdRecommendations component\r\n * @extends {React.PureComponent>}\r\n */\r\nclass UnbxdRecommendations extends React.PureComponent> {\r\n public render(): JSX.Element | null {\r\n return this.props.renderView(this.props);\r\n }\r\n}\r\n\r\nexport default UnbxdRecommendations;\r\n","import * as React from 'react';\r\nimport { Module } from '@msdyn365-commerce-modules/utilities';\r\nimport { IUnbxdRecommendationsViewProps } from './unbxd-recommendations';\r\nimport classnames from 'classnames';\r\nimport MsDyn365 from '@msdyn365-commerce/core';\r\nimport { UnbxdRecommendationsOptions, UnbxdWidgetConfig } from './unbxd-recommendations.data';\r\n\r\nconst defaultRecommendationSdk = 'https://libraries.unbxdapi.com/recs-sdk/v3.1.0/unbxd_recs_template_sdk.js';\r\nconst defaultUaLib = 'https://libraries.unbxdapi.com/ua-js/v1.0.2/uaLibrary.js';\r\n\r\nlet lastId = 0;\r\n\r\nexport default (props: IUnbxdRecommendationsViewProps) => {\r\n const { isBrowser } = MsDyn365;\r\n const [initialized, setInitialized] = React.useState(false);\r\n const divRef = React.useRef(null);\r\n const { widgetName, className } = props.config;\r\n\r\n const id = React.useMemo(() => {\r\n return `hei-unbxd-rec-widget-${++lastId}`;\r\n }, []);\r\n\r\n const currentSku = props.data.product?.result?.ItemId ?? '';\r\n\r\n React.useEffect(() => {\r\n const div = divRef.current;\r\n if (isBrowser && !initialized && div && widgetName) {\r\n setInitialized(true);\r\n\r\n const widgetDiv = document.createElement('div');\r\n widgetDiv.id = id;\r\n widgetDiv.setAttribute('data-hei-unbxd-widget', widgetName);\r\n\r\n div.appendChild(widgetDiv);\r\n }\r\n }, [widgetName]);\r\n\r\n const recommendationSdk = props.context.app.config.heiUnbxdRecommendationSdk ?? defaultRecommendationSdk;\r\n const uaLib = props.context.app.config.heiUnbxdAutosuggestCss ?? defaultUaLib;\r\n\r\n React.useEffect(() => {\r\n const body = window.document.getElementsByTagName('body')[0];\r\n if (isBrowser && body) {\r\n if (!window.unbxdRecInit) {\r\n window.unbxdRecInit = true;\r\n\r\n if (!window.UnbxdSiteName && props.context.app.config.heiUnbxdSiteKey) {\r\n window.UnbxdSiteName = props.context.app.config.heiUnbxdSiteKey;\r\n }\r\n\r\n {\r\n const userId = props.context.request.cookies.get('unbxd.userId').value ?? '';\r\n const siteKey = props.context.app.config.heiUnbxdSiteKey;\r\n const apiKey = props.context.app.config.heiUnbxdApiKey;\r\n\r\n // Inject unbxdRecommendationSdk\r\n const scriptTag = document.createElement('script');\r\n scriptTag.async = true;\r\n scriptTag.src = recommendationSdk;\r\n scriptTag.onload = () => {\r\n const widgets: UnbxdWidgetConfig[] = [];\r\n\r\n document.querySelectorAll('[data-hei-unbxd-widget]').forEach(elem => {\r\n widgets.push({\r\n name: elem.getAttribute('data-hei-unbxd-widget') ?? '',\r\n selector: elem.id\r\n });\r\n });\r\n\r\n const opts: UnbxdRecommendationsOptions = {\r\n widgets,\r\n userInfo: {\r\n userId,\r\n siteKey,\r\n apiKey\r\n },\r\n pageInfo: {\r\n pageType: currentSku ? 'PRODUCT' : 'HOME',\r\n productIds: currentSku ? [currentSku] : undefined\r\n },\r\n itemClickHandler: product => {\r\n let productUrl = `/${product.RecordId}.p`;\r\n try {\r\n const encodedName = product.ProductName?.replace(/\\./gi, '')\r\n .replace(/'/gi, '')\r\n .replace(/&/gi, '-')\r\n .replace(/[^a-zA-Z0-9&.]/gi, '-')\r\n .replace(/[-]{2,}/g, '-')\r\n .toLowerCase();\r\n productUrl = `/${encodedName}/${product.RecordId}.p`;\r\n } catch (err) {\r\n process.env.NODE_ENV === 'development' && console.log('UnbxdRecommendations', err);\r\n }\r\n\r\n window.location.assign(productUrl);\r\n process.env.NODE_ENV === 'development' && console.log('UnbxdRecommendations', product);\r\n }\r\n };\r\n\r\n process.env.NODE_ENV === 'development' && console.log('UnbxdRecommendations', opts);\r\n window.getUnbxdRecommendations && window.getUnbxdRecommendations(opts);\r\n };\r\n\r\n body.appendChild(scriptTag);\r\n }\r\n\r\n {\r\n // Inject unbxdUaLib\r\n const scriptTag = document.createElement('script');\r\n scriptTag.async = true;\r\n scriptTag.src = uaLib;\r\n body.appendChild(scriptTag);\r\n }\r\n }\r\n }\r\n }, [isBrowser, currentSku]);\r\n\r\n return ;\r\n};\r\n","const binding = { modules: {}, dataActions: {} };\n\n const registerActionId = (actionPath) => {\n if (binding.dataActions[actionPath] &&\n binding.dataActions[actionPath].default &&\n binding.dataActions[actionPath].default.prototype &&\n binding.dataActions[actionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[actionPath].default.prototype.id] = binding.dataActions[actionPath];\n } else {\n Object.keys(binding.dataActions[actionPath] || {}).forEach(exportName => {\n if (binding.dataActions[actionPath][exportName] &&\n binding.dataActions[actionPath][exportName].prototype &&\n binding.dataActions[actionPath][exportName].prototype.Action) {\n binding.dataActions[binding.dataActions[actionPath][exportName].prototype.id] = binding.dataActions[actionPath][exportName];\n }\n })\n }\n };\n\n const registerSanitizedActionPath = (sanitizedActionPath, dataAction) => {\n if (process.env.NODE_ENV === 'development') {\n if (!dataAction.default) {\n throw new Error('Data action path does not have a default export');\n }\n if (!(dataAction.default.prototype.id && binding.dataActions[dataAction.default.prototype.id]) || !binding.dataActions[sanitizedActionPath]) {\n binding.dataActions[sanitizedActionPath] = dataAction;\n }\n } else {\n binding.dataActions[sanitizedActionPath] = dataAction;\n if (!binding.dataActions[sanitizedActionPath].default) {\n throw new Error('Data action path ' + sanitizedActionPath + ' does not have a default export');\n }\n binding.dataActions[sanitizedActionPath].default.prototype.RegistrationId = sanitizedActionPath;\n if (binding.dataActions[sanitizedActionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[sanitizedActionPath].default.prototype.id] = sanitizedActionPath;\n }\n }\n };\n \n\n (binding.modules['unbxd-recommendations'] = {\n c: () => require('partner/modules/unbxd-recommendations/unbxd-recommendations.tsx'),\n $type: 'contentModule',\n da: [{name:'product', path:'@msdyn365-commerce-modules/retail-actions/dist/lib/get-selected-variant', runOn: 0}],\n \n iNM: false,\n ns: '__local__',\n n: 'unbxd-recommendations',\n p: '__local__',\n \n pdp: '',\n \n \n md: 'src/modules/unbxd-recommendations'\n });\n \n\n {\n const sanitizedActionPath = '@msdyn365-commerce-modules/retail-actions/dist/lib/get-selected-variant';\n let dataAction = require('@msdyn365-commerce-modules/retail-actions/dist/lib/get-selected-variant');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\n };\n export const viewDictionary = {};\n viewDictionary['__local__|__local__|modules|unbxd-recommendations|unbxd-recommendations'] = {\n c: () => require('partner/modules/unbxd-recommendations/unbxd-recommendations.view.tsx'),\n cn: '__local__-__local__-unbxd-recommendations'\n };\nwindow.__bindings__ = window.__bindings__ || {};\nwindow.__bindings__.viewDictionary = {\n ...window.__bindings__.viewDictionary || {},\n ...viewDictionary\n };","module.exports = React;","module.exports = ReactDOM;"],"names":["UnbxdRecommendations","React","render","this","props","renderView","lastId","_props$data$product$r","_props$data$product","_props$context$app$co","_props$context$app$co2","isBrowser","MsDyn365","initialized","setInitialized","divRef","widgetName","className","config","id","currentSku","data","product","result","ItemId","div","current","widgetDiv","document","createElement","setAttribute","appendChild","recommendationSdk","context","app","heiUnbxdRecommendationSdk","uaLib","heiUnbxdAutosuggestCss","body","window","getElementsByTagName","unbxdRecInit","UnbxdSiteName","heiUnbxdSiteKey","_props$context$reques","userId","request","cookies","get","value","siteKey","apiKey","heiUnbxdApiKey","scriptTag","async","src","onload","widgets","querySelectorAll","forEach","elem","_elem$getAttribute","push","name","getAttribute","selector","opts","userInfo","pageInfo","pageType","productIds","undefined","itemClickHandler","productUrl","RecordId","_product$ProductName","ProductName","replace","toLowerCase","err","location","assign","getUnbxdRecommendations","Module","moduleProps","ref","classnames","binding","modules","dataActions","c","require","$type","da","path","runOn","iNM","ns","n","p","pdp","md","registerSanitizedActionPath","sanitizedActionPath","dataAction","default","Error","prototype","RegistrationId","__bindings__","_objectSpread","viewDictionary","cn","module","exports","ReactDOM"],"sourceRoot":""}