"use strict";

exports.__esModule = true;
exports.useCreatePickerContentState = useCreatePickerContentState;
exports.usePickerContentState = usePickerContentState;
var _react = require("react");
var _react2 = require("@wix/bex-core/react");
var _state = require("../../state");
function useCreatePickerContentState() {
  const {
    createBILogger
  } = (0, _react2.useWixPatternsContainer)();
  const createCollection = (0, _react2.usePrivateCreateCollection)();
  return (0, _react.useCallback)(params => {
    const {
      events,
      initialSelect,
      modalState,
      ...collectionConfig
    } = params;
    const collection = createCollection({
      ...collectionConfig,
      queryName: modalState.queryName,
      paginationMode: modalState.paginationMode,
      useNewSelectAllLogic: true,
      fetchData: modalState.fetchData,
      limit: modalState.limit,
      events: {
        ...modalState.events,
        ...events
      }
    }, {
      paginationModeRef: modalState._paginationModeRef
    });
    return new _state.PickerContentState({
      modalState,
      collection,
      createBILogger,
      events,
      initialSelect
    });
  }, []);
}
function usePickerContentState(params) {
  const createPickerContentState = useCreatePickerContentState();
  const [state] = (0, _react.useState)(() => createPickerContentState(params));
  (0, _react.useEffect)(() => {
    state.initialSelect = params.initialSelect;
  }, [params.initialSelect]);
  return state;
}
//# sourceMappingURL=usePickerContentState.js.map