recommendations-widget-assets-292d12d0de95a07b40e9.js 6.0 KB

1
  1. (()=>{"use strict";var e={8432:(e,t,n)=>{n.r(t)}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{const e=React;var t=n.n(e);const r=ReactDOM;var a=n.n(r);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function s(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return l(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(this,arguments)}function f(e){var n=Object.keys(e.trackingTags).reduce((function(t,n){return t["data-webm-".concat(n.toLowerCase())]=e.trackingTags[n],t}),{});return t().createElement("a",p({href:e.detailsUrl},n),t().createElement("div",{className:"card rec-card"},t().createElement("img",{className:"card-img-top",src:e.photoUrl}),t().createElement("div",{className:"card-body"},t().createElement("h6",{className:"card-title"},e.title),t().createElement("p",{className:"card-text"},e.priceText))))}var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(h,e);var n,r,a,o,m=(a=h,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=u(a);if(o){var n=u(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return s(this,e)});function h(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(t=m.call(this,e)).state={selection:e.state||""},t.onSelectState=t.onSelectState.bind(l(t)),t}return n=h,(r=[{key:"onSelectState",value:function(e){this.setState({selection:e.target.value})}},{key:"render",value:function(){var e=this,n=Object.keys(this.props.states).map((function(n){return t().createElement("option",{key:n,value:n},e.props.states[n])})),r=n.length>0,a=this.props.items.filter((function(t){return!r||!e.state.selection||t.state===e.state.selection})).slice(0,3).map((function(e){return t().createElement(f,p({key:e.itemId},e))}));return t().createElement("div",{className:"rec-items-wrapper"},t().createElement("div",{className:"section-header"},t().createElement("h5",{className:"section-title"},this.props.heading),r&&t().createElement("select",{value:this.state.selection,onChange:this.onSelectState},t().createElement("option",{value:""},"Any Location"),n)),a.length>0&&t().createElement("div",{className:"rec-items"},a),0===a.length&&t().createElement("div",null,this.props.noItemsMessage),this.props.viewMoreUrl&&t().createElement("div",{className:"view-more"},t().createElement("a",{href:this.props.viewMoreUrl},this.props.viewMoreText," >")))}}])&&c(n.prototype,r),h}(t().Component);function h(){return h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},h.apply(this,arguments)}function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var y=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._container=t,this._baseUrl=n.url}var n,r;return n=e,(r=[{key:"render",value:function(){var e,n,r,o=this,c=this._container.dataset.state;fetch((e=this._baseUrl,n=this._container,r=["placement=".concat(n.dataset.placement),"template=".concat(n.dataset.template),"variation=".concat(n.dataset.variation),"showStateFilter=".concat(n.dataset.showState)],"".concat(e,"?").concat(r.join("&")))).then((function(e){return e.json()})).then((function(e){return a().render(t().createElement(m,h({},e,{state:c})),o._container)})).catch(console.error)}},{key:"destroy",value:function(){a().unmountComponentAtNode(this._container)}}])&&d(n.prototype,r),e}();function v(e,t){var n=new URL(e,location);t&&t.dataset.placement&&(n.searchParams.append("placement",t.dataset.placement),n.searchParams.append("state",t.dataset.state),n.searchParams.append("template",t.dataset.template),n.searchParams.append("variation",t.dataset.variation),n.searchParams.append("showStateFilter",t.dataset.showState),n.searchParams.append("maxItems",t.dataset.maxItems),fetch(n).then((function(e){return e.text()})).then((function(e){return $(t).html(e)})).catch(console.error))}n(8432),function(e){for(var t=document.querySelectorAll(e.selector),n={url:e.ajaxUrl},r=0;r<t.length;r++)"list"===t[r].dataset.template?v(e.ajaxUrl,t[r]):new y(t[r],n).render()}(window.Csn.PageData.Recommendations)})()})();