"use strict";

exports.__esModule = true;
exports.useLayoutSwitchCollection = void 0;
var _react = require("@wix/bex-core/react");
var _LayoutSwitchState = require("../state/LayoutSwitchState");
var _useOptionalCachedState = require("./useOptionalCachedState");
const useLayoutSwitchCollection = config => {
  const container = (0, _react.useWixPatternsContainer)();
  const containerOverrides = (0, _react.useWixPatternsContainerOverrides)();
  const createCollection = (0, _react.useCreateCollection)();
  const createOptimisticActions = (0, _react.useCreateOptimisticActions)();
  const state = (0, _useOptionalCachedState.useOptionalCachedState)(() => {
    const collection = createCollection(config);
    const spreadsheet = config.spreadsheet ? {
      ...config.spreadsheet,
      createOptimisticActions: c => createOptimisticActions(c)
    } : undefined;
    return new _LayoutSwitchState.LayoutSwitchState({
      collection,
      container,
      containerOverrides,
      table: config.table,
      grid: config.grid,
      spreadsheet
    });
  });
  return state;
};
exports.useLayoutSwitchCollection = useLayoutSwitchCollection;
//# sourceMappingURL=useLayoutSwitchCollection.js.map