Liferay.Loader.define("@liferay/analytics-settings-web@5.0.47/js/components/table/Context",["module","exports","require","liferay!frontend-js-react-web$react","../../utils/filter","../../utils/pagination","./utils"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.useDispatch=t.useData=t.Events=void 0;var a=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var n=a?Object.getOwnPropertyDescriptor(e,o):null;n&&(n.get||n.set)?Object.defineProperty(r,o,n):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),o=r("../../utils/filter"),n=r("../../utils/pagination"),c=r("./utils");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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}let e;t.Events=e,function(e){e.ChangeFilter="CHANGE_FILTER",e.ChangeItems="CHANGE_ITEMS",e.ChangeKeywords="CHANGE_KEYWORDS",e.ChangePagination="CHANGE_PAGINATION",e.FormatData="FORMAT_DATA",e.ToggleGlobalCheckbox="TOGGLE_CHECKBOX"}(e||(t.Events=e={}));const i={filter:o.DEFAULT_FILTER,formattedItems:{},globalChecked:!1,internalKeywords:"",keywords:"",pagination:n.DEFAULT_PAGINATION,rows:[]},d=(0,a.createContext)(i),l=(0,a.createContext)(null),useData=()=>(0,a.useContext)(d);t.useData=useData;const useDispatch=()=>(0,a.useContext)(l);function reducer(t,r){switch(r.type){case e.ChangeFilter:return _objectSpread(_objectSpread({},t),{},{filter:_objectSpread(_objectSpread({},t.filter),r.payload)});case e.ChangeItems:{const e=_objectSpread(_objectSpread({},t.formattedItems),{},{[r.payload]:_objectSpread(_objectSpread({},t.formattedItems[r.payload]),{},{checked:!t.formattedItems[r.payload].checked})});return _objectSpread(_objectSpread({},t),{},{formattedItems:e,globalChecked:(0,c.getGlobalChecked)(e)})}case e.ChangeKeywords:return _objectSpread(_objectSpread({},t),{},{keywords:r.payload});case e.FormatData:{const{items:e,page:a,pageSize:o,totalCount:n}=r.payload,i=_objectSpread(_objectSpread({},(0,c.getFormattedItems)(e)),t.formattedItems);return _objectSpread(_objectSpread({},t),{},{formattedItems:i,globalChecked:(0,c.getGlobalChecked)(i),pagination:{maxCount:t.pagination.maxCount||n,page:a,pageSize:o,totalCount:n},rows:e.map((({id:e})=>e))})}case e.ChangePagination:return _objectSpread(_objectSpread({},t),{},{pagination:_objectSpread(_objectSpread({},t.pagination),r.payload)});case e.ToggleGlobalCheckbox:{const{globalChecked:e,items:a}=r.payload;return _objectSpread(_objectSpread({},t),{},{formattedItems:(0,c.updateFormattedItems)(_objectSpread(_objectSpread({},(0,c.getFormattedItems)(a)),t.formattedItems),e),globalChecked:e})}default:throw new Error}}t.useDispatch=useDispatch;var _default=({children:e})=>{const[t,r]=(0,a.useReducer)(reducer,i);return a.default.createElement(d.Provider,{value:t},a.default.createElement(l.Provider,{value:r},e))};t.default=_default}}));
//# sourceMappingURL=Context.js.map