"use strict";

exports.__esModule = true;
exports.useSetupWidget = void 0;
var _bexCore = require("@wix/bex-core");
var _react = require("@wix/bex-core/react");
var _react2 = require("react");
/**
 * Creates a {@link SetupWidgetState} instance and wires its lifecycle, then
 * returns it to be passed to the `SetupWidget` component — the same pattern as
 * `useCollection` → `CollectionState`.
 *
 * The widget owns loading / error / refetch; the returned state also exposes a
 * public API to read the steps / progress and to change a step's status
 * (`state.steps`, `state.getStep`, `state.setStepStatus`).
 *
 * @example
 * const setup = useSetupWidget({ fetchData });
 * return <SetupWidget state={setup} />;
 */
const useSetupWidget = ({
  fetchData
}) => {
  const container = (0, _react.useWixPatternsContainer)();
  const [state] = (0, _react2.useState)(() => new _bexCore.SetupWidgetState({
    container,
    fetchData
  }));
  (0, _react2.useEffect)(() => state.init(), [state]);
  return state;
};
exports.useSetupWidget = useSetupWidget;
//# sourceMappingURL=useSetupWidget.js.map