Liferay.Loader.define("@liferay/frontend-data-set-web@1.0.31/views/table/dnd_table/ContextProvider",["module","exports","require","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./TableContext"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;i(r("liferay!frontend-js-react-web$prop-types"));var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=n?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),o=i(r("./TableContext"));function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}function u(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 l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(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 f({children:e,columnNames:t}){const[r,a]=(0,n.useState)(null),[i,u]=(0,n.useState)(new Map),[c,f]=(0,n.useState)(null),[s,d]=(0,n.useState)(!0),p=(0,n.useMemo)((()=>t.every((e=>i.has(e)))),[i,t]),b=(0,n.useCallback)(((e,n)=>{p&&u((o=>{const a=o.get(e),i=a.width>n;let u=0;o.forEach((e=>{u+=e.width}));const c=t[t.indexOf(e)+1],f=o.get(c),s=u<r;if(i&&s&&!(null==f?void 0:f.resizable)||n<40)return d(!1),o;d(!0);const p=new Map(o);return i&&s&&p.set(c,l(l({},f),{},{width:f.width+a.width-n})),p.set(e,l(l({},a),{},{width:n})),p}))}),[t,r,p]);return n.default.createElement(o.default.Provider,{value:{columnDefinitions:i,columnNames:t,draggingAllowed:s,draggingColumnName:c,isFixed:p,registerColumn:(e,t,r)=>{u((n=>{const o=new Map(n);return o.set(e,{resizable:r,width:t}),o}))},resizeColumn:b,tableWidth:r,updateDraggingAllowed:d,updateDraggingColumnName:f,updateTableWidth:a}},e)}f.defaultProps={columnNames:[]};var s=f;t.default=s}}));
//# sourceMappingURL=ContextProvider.js.map