import r from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/toConsumableArray";import{useState as n,useMemo as o,useEffect as i}from"react";import{isEmpty as c}from"lodash";import{SortDirection as a}from"react-virtualized";import{ColumnType as u}from"../constants.js";function f(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var p=function(r,e,n){var o=t(r),i=e===u.lastActive;return o.sort((function(r,t){var o=r[e],c=t[e],u=!o||"string"==typeof o&&"null"===o.toLowerCase(),f=!c||"string"==typeof c&&"null"===c.toLowerCase();return u&&(0!==o||i)?1:f&&(0!==c||i)?-1:"string"==typeof o&&"string"==typeof c?n===a.ASC?o.localeCompare(c):c.localeCompare(o):n===a.ASC?o>=c?1:-1:c>=o?1:-1})),o},s=function(r,t,f,s,m){var b=n(u.distance),y=e(b,2),O=y[0],d=y[1],h=n(a.ASC),j=e(h,2),v=j[0],g=j[1],w=o((function(){if(!t)return null;var e=new Set(f.map((function(r){return r.id}))),n=e.size>0?e:new Set(m||[]),o=t.filter((function(e){return e.id!==(null==r?void 0:r.id)&&n.has(e.id)})),i=p(o,O,v),a=t.filter((function(r){return!n.has(r.id)})),u=p(a,O,v);return(r&&!c(r)?[r]:[]).concat(i).concat(u).map((function(r){return l(l({},r),{},{checked:n.has(r.id)})}))}),[t,O,v,r,f,m]);return i((function(){null!==w&&s(!1)}),[w,s]),[O,d,v,g,w]};export{s as useSortedWells};
//# sourceMappingURL=useSortedWells.js.map
