Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/utils/index",["module","exports","require","frontend-js-web","./odata"],(function(e,t,r){var a;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(e){return new Promise((t=>{setTimeout((()=>t()),e)}))},t.getData=function(e,t){const r=new URL(e);t&&r.searchParams.append("search",t);return(0,n.fetch)(r,{method:"GET"}).then((e=>e.json()))},t.getSchemaString=function(e,t){return Array.isArray(t)?t.reduce(((e,t)=>e[t]),e):e[t]},t.liferayNavigate=function(e){Liferay.SPA?Liferay.SPA.app.navigate(e):window.location.href=e},t.isValuesArrayChanged=function(e=[],t=[]){if(e.length!==t.length)return!0;const r=e.map((e=>e.value||e)).sort(),a=t.map((e=>e.value||e)).sort();let n=!1;return r.forEach(((e,t)=>{e!==a[t]&&(n=!0)})),n},t.getValueFromItem=s,t.getValueDetailsFromItem=function(e,t){if(!t)return null;let r=t;const a=[];let n=e;Array.isArray(t)?(r=t[0],t.forEach((e=>{let t=e;if("LANG"===e){const e=Liferay.ThemeDisplay.getLanguageId(),r=Liferay.ThemeDisplay.getBCP47LanguageId();t=n[e]?e:n[r]?r:Liferay.ThemeDisplay.getDefaultLanguageId()}a.push(t),n&&(n=n[t])}))):(a.push(t),n=n[t]);return{rootPropertyName:r,value:n,valuePath:a}},t.formatItemChanges=function(e){return Object.values(e).reduce(((e,{value:t,valuePath:r})=>{const a=r.reduceRight(((e,t)=>({[t]:e})),t);return u(u({},e),a)}),{})},t.formatActionURL=function(e,t){return e.replace(new RegExp("{(.*?)}","mg"),(e=>s(t,e.substring(1,e.length-1).split(".")))).replace(new RegExp("(%7B.*?%7D)","mg"),(e=>s(t,e.substring(3,e.length-3).split("."))))},t.getRandomId=function(){return Math.random().toString(36).substr(2,9)},t.createSortingString=function(e){if(!e.length)return null;return e.map((e=>"".concat(Array.isArray(e.fieldName)?e.fieldName[0]:e.fieldName,":").concat(e.direction))).join(",")},t.getFiltersString=l,t.loadData=async function(e,t,r,a,i,o=1,u=[]){const c=e.startsWith("/")?themeDisplay.getPortalURL()+themeDisplay.getPathContext()+e:e,s=new URL(c),f=s.searchParams.get("filter");s.searchParams.delete("filter"),s.searchParams.append("currentURL",t),(f||r.length)&&s.searchParams.append("filter",l(r,f));s.searchParams.append("page",o),s.searchParams.append("pageSize",i),a&&s.searchParams.append("search",a);u.length&&s.searchParams.append("sort",u.map((e=>"".concat(e.key,":").concat(e.direction))).join(","));const g=await(0,n.fetch)(s,{headers:{Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"},method:"GET"});return{data:await g.json(),ok:g.ok,status:g.status}},t.getCurrentItemUpdates=function(e,t,r,a,n,i,o){const c=e.find((e=>e[r]===a)),l=t[a];if(!l)return{[n]:{value:i,valuePath:o}};if(c&&s(c,o)===i){return Object.entries(l).reduce(((e,[t,r])=>t!==n?u(u({},e),{},{[t]:r}):e),{})}return u(u({},l),{},{[n]:{value:i,valuePath:o}})};var n=r("frontend-js-web"),i=(a=r("./odata"))&&a.__esModule?a:{default:a};function o(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 u(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}function s(e,t){return t?Array.isArray(t)?t.reduce(((e,t)=>"LANG"===t?e[Liferay.ThemeDisplay.getLanguageId()]||e[Liferay.ThemeDisplay.getDefaultLanguageId()||e[Liferay.ThemeDisplay.getBCP47LanguageId()]]:e[t]),e):e[t]:null}function l(e,t){let r="";return t&&(r+=t),t&&e.length&&(r+=" and "),e.length&&(r+=(0,i.default)(e)),r}}}));
//# sourceMappingURL=index.js.map