import _extends from "@babel/runtime/helpers/extends";
import * as React from 'react';
import { renderImperatively } from '../utils/dom';
import Picker from './Picker';
export var prompt = function prompt(props) {
  return new Promise(function (resolve) {
    var _renderImperatively = renderImperatively( /*#__PURE__*/React.createElement(Picker, _extends({}, props, {
      onConfirm: function onConfirm(value, items) {
        var _props$onConfirm;

        (_props$onConfirm = props.onConfirm) === null || _props$onConfirm === void 0 ? void 0 : _props$onConfirm.call(props, value, items);
        close();
        resolve({
          value: value,
          items: items
        });
      },
      onCancel: function onCancel() {
        var _props$onCancel;

        (_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props);
        close();
        resolve({
          value: null,
          items: []
        });
      }
    }))),
        close = _renderImperatively.close;
  });
};