Liferay.Loader.define("commerce-frontend-js@4.0.52/utilities/index",["module","exports","require","frontend-js-web","./quantities"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getData=function(e,t,r,a){const o=new URL(e,Liferay.ThemeDisplay.getPortalURL());t&&o.searchParams.append("search",t);r&&o.searchParams.append("page",r);a&&o.searchParams.append("pageSize",a);return(0,n.fetch)(o,i({},f)).then((e=>e.json()))},t.liferayNavigate=function(e){Liferay.SPA?Liferay.SPA.app.navigate(e):window.location.href=e},t.getObjectFromPath=s,t.formatAutocompleteItem=function(e,t,r,n){const a=s(Array.isArray(t)?t:[t],e),o=s(Array.isArray(n)?n:[n],r);return i(i({},a),o)},t.getValueFromItem=u,t.formatActionUrl=function(e,t){var r=new RegExp("{(.*?)}","mg"),n=e.replace(r,(e=>u(t,e.substring(1,e.length-1).split("."))));return r=new RegExp("(%7B.*?%7D)","mg"),n=n.replace(r,(e=>u(t,e.substring(3,e.length-3).split("."))))},t.getRandomId=function(){return Math.random().toString(36).substr(2,9)},t.sortByKey=function(e,t){const r=e.reduce(((e,r)=>"number"==typeof r[t]?i(i({},e),{},{sorted:i(i({},e.sorted),{},{[r[t]]:r})}):i(i({},e),{},{unsortable:e.unsortable.concat(r)})),{sorted:{},unsortable:[]});return[...Object.values(r.sorted),...r.unsortable]},t.isProductPurchasable=function(e,t,r){if(!1===r)return!1;if(t.allowBackOrder)return!0;if(e.stockQuantity>(0,a.getProductMinQuantity)(t))return!0;return!1},t.fetchParams=t.fetchHeaders=void 0;var n=r("frontend-js-web"),a=r("./quantities");function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=new Headers({Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"});t.fetchHeaders=e;const f={headers:e};function s(e,t){return e.reduceRight(((e,t)=>({["LANG"===t?Liferay.ThemeDisplay.getLanguageId():t]:e})),t)}function u(e,t){return t&&"string"!=typeof e?Array.isArray(t)?t.reduce(((e,t)=>"LANG"===t?e[Liferay.ThemeDisplay.getLanguageId()]||e[Liferay.ThemeDisplay.getDefaultLanguageId()]:e[t]),e):e[t]:null}t.fetchParams=f}}));
//# sourceMappingURL=index.js.map