Liferay.Loader.define("commerce-frontend-js@4.0.52/components/price/Price",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../utilities/eventsDefinitions","./util/index"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=s(a("liferay!frontend-js-react-web$classnames")),n=(s(a("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var c=r?Object.getOwnPropertyDescriptor(e,n):null;c&&(c.get||c.set)?Object.defineProperty(a,n,c):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),c=a("../../utilities/eventsDefinitions"),l=a("./util/index");function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function u(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?o(Object(a),!0).forEach((function(t){f(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function f(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function p({compact:e,displayDiscountLevels:t,namespace:a,netPrice:i,price:s,standalone:o}){const[f,p]=(0,n.useState)((0,l.adaptLegacyPriceModel)(s)),d=t?(0,l.collectDiscountLevels)(f):[],m=(0,l.isNonnull)(f.discountPercentage,...d),y=(0,l.isNonnull)(f.promoPrice),g=({cpInstance:e})=>p((t=>u(u({},t),(0,l.adaptLegacyPriceModel)(e.prices))));(0,n.useEffect)((()=>(a&&Liferay.on("".concat(a).concat(c.CP_INSTANCE_CHANGED),g),()=>{a&&Liferay.detach("".concat(a).concat(c.CP_INSTANCE_CHANGED),g)})),[a]),(0,n.useEffect)((()=>{p((0,l.adaptLegacyPriceModel)(s))}),[s]);const b=n.default.createElement(n.default.Fragment,null,n.default.createElement("span",{className:"price-label"},Liferay.Language.get("list-price")),n.default.createElement("span",{className:(0,r.default)({"price-value":!0,"price-value-inactive":y||m})},f.priceFormatted),y&&n.default.createElement(n.default.Fragment,null,n.default.createElement("span",{className:"price-label"},Liferay.Language.get("sale-price")),n.default.createElement("span",{className:(0,r.default)("price-value price-value-promo",m&&"price-value-inactive")},f.promoPriceFormatted)),m&&n.default.createElement(n.default.Fragment,null,n.default.createElement("span",{className:"price-label"},Liferay.Language.get("discount")),n.default.createElement("span",{className:"price-value price-value-discount"},t?d.map(((e,t)=>n.default.createElement("span",{className:"price-value-percentages",key:t},"00"===e.slice(-2)?e.slice(0,e.length-3):e))):n.default.createElement("span",{className:"price-value-percentage"},"–",f.discountPercentage,"%")),n.default.createElement("span",{className:"price-label"},i?Liferay.Language.get("net-price"):Liferay.Language.get("gross-price")),n.default.createElement("span",{className:"price-value price-value-final"},f.finalPriceFormatted)));return o?b:n.default.createElement("div",{className:(0,r.default)({compact:e,price:!0})},b)}p.defaultProps={compact:!1,displayDiscountLevels:!1,namespace:"",netPrice:!0,standalone:!1};var d=p;t.default=d}}));
//# sourceMappingURL=Price.js.map