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