Liferay.Loader.define("commerce-frontend-js@4.0.52/components/summary/Summary",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../utilities/AJAX/index","../../utilities/eventsDefinitions"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=o(a("@frontend-taglib-clay$clayui/loading-indicator")),r=(o(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={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),n=o(a("../../utilities/AJAX/index")),u=a("../../utilities/eventsDefinitions");function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function o(e){return e&&e.__esModule?e:{default:e}}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var a,l,r=function(e,t){if(null==e)return{};var a,l,r={},n=Object.keys(e);for(l=0;l<n.length;l++)a=n[l],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(l=0;l<n.length;l++)a=n[l],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function d(){return r.default.createElement("div",{className:"col-12"},r.default.createElement("hr",null))}function f(e){return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:"col-6 col-md-9"},r.default.createElement("span",{className:"summary-table-item"},e.label)),r.default.createElement("div",{className:"col-6 col-md-3"},r.default.createElement("span",{className:"summary-table-item"},e.value)))}function m(e){return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:"col-6 col-md-9"},r.default.createElement("h4",{className:"my-2 summary-table-item-big"},e.label)),r.default.createElement("div",{className:"col-6 col-md-3"},r.default.createElement("h4",{className:"my-2 summary-table-item-big"},e.value)))}function y(e){return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:"col-6 col-md-9 text-danger"},r.default.createElement("span",{className:"summary-table-item"},e.label)),r.default.createElement("div",{className:"col-6 col-md-3 text-danger"},r.default.createElement("span",{className:"summary-table-item"},e.value)))}function b(e){const{style:t}=e,a=s(e,["style"]);let l;switch(t){case"big":l=m;break;case"divider":l=d;break;case"danger":l=y;break;default:l=f}return r.default.createElement(l,a)}function g({apiUrl:e,dataMapper:t,datasetDisplayId:a,isLoading:i,items:o=[],summaryData:s}){const[d,f]=(0,r.useState)(o),m=(0,r.useCallback)((e=>"function"==typeof t?t(e):e),[t]),y=(0,r.useCallback)((({id:t=null})=>{if(!t||a!==t)return n.default.GET(e).then((e=>f(m(e))))}),[e,a,m]);return(0,r.useEffect)((()=>e&&a?(Liferay.on(u.DATASET_DISPLAY_UPDATED,y),y({}),()=>Liferay.detach(u.DATASET_DISPLAY_UPDATED,y)):()=>{}),[e,a,y]),(0,r.useEffect)((()=>(s&&Object.keys(s).length>0&&f(m(s)),()=>{})),[m,s]),r.default.createElement("div",{className:"row summary-table text-right"},d.map(((e,t)=>r.default.createElement(b,c({key:t},e)))),i&&r.default.createElement("div",{className:"summary-table-loader"},r.default.createElement(l.default,null)))}g.defaultProps={dataMapper:e=>[{label:Liferay.Language.get("subtotal"),value:e.subtotalFormatted},{label:Liferay.Language.get("subtotal-discount"),value:e.subtotalDiscountAmountFormatted},{label:Liferay.Language.get("total-discount"),value:e.totalDiscountAmountFormatted},{label:Liferay.Language.get("promotion-code"),value:e.couponCode||"--"},{label:Liferay.Language.get("tax"),value:e.taxAmountFormatted},{label:Liferay.Language.get("delivery"),value:e.shippingAmountFormatted},{label:Liferay.Language.get("delivery-discount"),value:e.shippingDiscountAmountFormatted},{style:"divider"},{label:Liferay.Language.get("total"),style:"big",value:e.totalFormatted}],isLoading:!1};var p=g;t.default=p}}));
//# sourceMappingURL=Summary.js.map