"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),l=require("react"),r=require("../../constants.js"),n=require("./useFilterPruneEffect.js"),s=require("./useWellReconciliation.js"),i=require("./useSelectionHandlers.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(e),o=c(t);function a(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),l.push.apply(l,r)}return l}exports.useWellSelection=function(e){var t=e.subjectWellId,c=e.subjectWell,f=e.wells,d=e.filteredWells,S=e.externalOffsets,b=e.rawWellsWithSubject,W=e.offsetSettings,p=e.maxOffsetWellNumber,O=e.maxOffsetSize,j=e.open,h=e.isAllWellsLoaded,m=e.fetchSearchedWells,y=e.filters,g=e.filterMutationSeq,v=e.lastFilterMutationSource,P=e.includeHidden,w=l.useState([]),E=o.default(w,2),R=E[0],q=E[1],x=l.useRef(!1),C=l.useRef(0),M=l.useState((function(){var e;return null!==(e=null==W?void 0:W.lastSelectionZone)&&void 0!==e?e:null})),A=o.default(M,2),I=A[0],L=A[1],U=l.useState((null==W?void 0:W.wellSection)||r.ALL_SECTION_KEY),Z=o.default(U,2),k=Z[0],D=Z[1],F=l.useState([]),H=o.default(F,2),_=H[0],N=H[1];n.useFilterPruneEffect({filterMutationSeq:g,lastFilterMutationSource:v,open:j,filters:y,includeHidden:P,subjectWellId:t,setSelectedWells:q,setCurrentSelectionZone:L,hasUserSelectionEditsRef:x});var z=s.useWellReconciliation({subjectWell:c,wells:f,offsetSettings:W,open:j,isAllWellsLoaded:h,fetchSearchedWells:m,setSelectedWells:q,hasUserSelectionEditsRef:x}).isReconciled,T=i.useSelectionHandlers({subjectWell:c,wells:f,filteredWells:d,externalOffsets:S,rawWellsWithSubject:b,maxOffsetWellNumber:p,maxOffsetSize:O,fetchSearchedWells:m,setSelectedWells:q,setCurrentSelectionZone:L,setSelectedWellSection:D,hasUserSelectionEditsRef:x}),G=l.useCallback((function(){x.current=!0}),[]),K=l.useCallback((function(){C.current+=1}),[]),Y=l.useMemo((function(){return R.find((function(e){return e.id===t}))?R.length-1:R.length}),[R,t]),B=l.useMemo((function(){return R.map((function(e){return e.id}))}),[R]);return function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?a(Object(l),!0).forEach((function(t){u.default(e,t,l[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):a(Object(l)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))}))}return e}({selectedWells:R,setSelectedWells:q,selectedWellsCount:Y,selectedWellIds:B,isReconciled:z,currentSelectionZone:I,setCurrentSelectionZone:L,selectedWellSection:k,setSelectedWellSection:D,loadingAssetIds:_,setLoadingAssetIds:N,searchGenerationRef:C,hasUserSelectionEditsRef:x,markUserEdit:G,abandonPendingSearch:K},T)};
//# sourceMappingURL=useWellSelection.js.map
