"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/toConsumableArray"),n=require("react"),u=require("lodash"),i=require("react-virtualized"),o=require("../constants.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),l=c(r),f=c(t);function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function d(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){a.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var p=function(e,r,t){var n=f.default(e),u=r===o.ColumnType.lastActive;return n.sort((function(e,n){return e[r]||0===e[r]&&!u?n[r]||0===n[r]&&!u?t===i.SortDirection.ASC?e[r]>=n[r]?1:-1:n[r]>=e[r]?1:-1:-1:1})),n};exports.useSortedWells=function(e,r,t,c,a){var f=n.useState(o.ColumnType.distance),s=l.default(f,2),b=s[0],y=s[1],O=n.useState(i.SortDirection.ASC),j=l.default(O,2),v=j[0],m=j[1],h=n.useState(null),P=l.default(h,2),S=P[0],g=P[1];return n.useEffect((function(){if(r&&!a){var n=t.map((function(e){return e.id})),i=t.filter((function(r){return r.id!==(null==e?void 0:e.id)})),o=p(i,b,v),l=r.filter((function(e){return!n.includes(e.id)})),f=p(l,b,v),s=(u.isEmpty(e)?[]:[e]).concat(o).concat(f).map((function(e){return t.find((function(r){return r.id===e.id}))?d(d({},e),{},{checked:!0}):d(d({},e),{},{checked:!1})}));g(s),c(!1)}}),[r,b,v,e,t,a]),[b,y,v,m,S]};
