Liferay.Loader.define("data-engine-taglib@3.3.53/data_layout_builder/js/hooks/useData",["module","exports","require","@frontend-taglib-clay$clayui/data-provider","frontend-js-web"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useData=function useData({dataDefinitionId:e,dataLayoutId:t}){let a=themeDisplay.getPathContext();a&&"/"!==a||(a="");const{resource:o}=(0,n.useResource)({fetch:customFetch({defaultData:i,id:e,parse:parseDataDefinition}),fetchPolicy:"cache-first",fetchRetry:{attempts:0},link:"".concat(window.location.origin).concat(a,"/o/data-engine/v2.0/data-definitions/").concat(e)}),{resource:r}=(0,n.useResource)({fetch:customFetch({defaultData:c,id:t,parse:parseDataLayout}),fetchPolicy:"cache-first",fetchRetry:{attempts:0},link:"".concat(window.location.origin).concat(a,"/o/data-engine/v2.0/data-layouts/").concat(t)});return{dataDefinition:o,dataLayout:r}};var n=a("@frontend-taglib-clay$clayui/data-provider"),o=a("frontend-js-web");function _objectWithoutProperties(e,t){if(null==e)return{};var a,n,o=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var a,n,o={},r=Object.keys(e);for(n=0;n<r.length;n++)a=r[n],t.indexOf(a)>=0||(o[a]=e[a]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)a=r[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(o[a]=e[a])}return o}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const omit=(e,t)=>{const a=function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({},e);return t.forEach((e=>{delete a[e]})),a},parseDataLayout=e=>{const t=omit(e,["dataRules","dataLayoutPages","description","name"]),{paginationMode:a}=t;return{dataLayout:_objectWithoutProperties(t,["paginationMode"]),paginationMode:a}},parseDataDefinition=e=>{const t=omit(e,["defaultLanguageId","defaultDataLayout"]),{availableLanguageIds:a,description:n,name:o}=t;return{availableLanguageIds:a,dataDefinition:_objectWithoutProperties(t,["availableLanguageIds","description","name"]),description:n,name:o}},e="0",r=404,customFetch=({defaultData:t,id:a,parse:n})=>async(i,c)=>{if(a===e)return t;const u=await(0,o.fetch)(i,c);if(u.ok)return n(await u.json());if(u.status===r)return t;throw u},i={dataDefinition:{dataDefinitionFields:[]}},c={dataLayoutFields:{},dataLayoutPages:[],dataRules:[],paginationMode:"single-page"}}}));
//# sourceMappingURL=useData.js.map