/**
 * formiga-reactstrap v0.1.7
 *
 * Copyright (c) Donato Lorenzo <donato@afialapis.com>
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
import React, { useState, useRef, useEffect, useCallback } from 'react';
import PropTypes from 'prop-types';
import { useForm, useInput, useInputFilter } from 'formiga';
import { Button, FormGroup, Label, InputGroup, InputGroupText, Input } from 'reactstrap';
import { DatePicker } from 'reactstrap-date-picker';

var FIconBase = props => {
  var styles = {
    svg: {
      display: 'inline-block',
      verticalAlign: 'middle'
    },
    path: {
      fill: props.color
    }
  };
  var lpaths = typeof props.icon == "string" ? [props.icon] : props.icon;
  return /*#__PURE__*/React.createElement("svg", {
    style: styles.svg,
    width: "".concat(props.size, "px"),
    height: "".concat(props.size, "px"),
    viewBox: "0 0 1024 1024"
  }, lpaths.map((p, i) => /*#__PURE__*/React.createElement("path", {
    key: i,
    style: styles.path,
    d: p
  })));
};
FIconBase.propTypes = {
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).isRequired,
  size: PropTypes.number,
  color: PropTypes.string
};
FIconBase.defaultProps = {
  size: 16
};

var library = {
  'text': "M0 64h1024v128h-1024zM0 256h1024v128h-1024zM0 448h1024v128h-1024zM0 640h1024v128h-1024zM0 832h1024v128h-1024z",
  'checkmark': ["M864 128l-480 480-224-224-160 160 384 384 640-640z"],
  'color': "M986.51 37.49c-49.988-49.986-131.032-49.986-181.020 0l-172.118 172.118-121.372-121.372-135.764 135.764 106.426 106.426-472.118 472.118c-8.048 8.048-11.468 18.958-10.3 29.456h-0.244v160c0 17.674 14.328 32 32 32h160c0 0 2.664 0 4 0 9.212 0 18.426-3.516 25.456-10.544l472.118-472.118 106.426 106.426 135.764-135.764-121.372-121.372 172.118-172.118c49.986-49.988 49.986-131.032 0-181.020zM173.090 960h-109.090v-109.090l469.574-469.572 109.088 109.088-469.572 469.574z",
  'cross': "M1014.662 822.66c-0.004-0.004-0.008-0.008-0.012-0.010l-310.644-310.65 310.644-310.65c0.004-0.004 0.008-0.006 0.012-0.010 3.344-3.346 5.762-7.254 7.312-11.416 4.246-11.376 1.824-24.682-7.324-33.83l-146.746-146.746c-9.148-9.146-22.45-11.566-33.828-7.32-4.16 1.55-8.070 3.968-11.418 7.31 0 0.004-0.004 0.006-0.008 0.010l-310.648 310.652-310.648-310.65c-0.004-0.004-0.006-0.006-0.010-0.010-3.346-3.342-7.254-5.76-11.414-7.31-11.38-4.248-24.682-1.826-33.83 7.32l-146.748 146.748c-9.148 9.148-11.568 22.452-7.322 33.828 1.552 4.16 3.97 8.072 7.312 11.416 0.004 0.002 0.006 0.006 0.010 0.010l310.65 310.648-310.65 310.652c-0.002 0.004-0.006 0.006-0.008 0.010-3.342 3.346-5.76 7.254-7.314 11.414-4.248 11.376-1.826 24.682 7.322 33.83l146.748 146.746c9.15 9.148 22.452 11.568 33.83 7.322 4.16-1.552 8.070-3.97 11.416-7.312 0.002-0.004 0.006-0.006 0.010-0.010l310.648-310.65 310.648 310.65c0.004 0.002 0.008 0.006 0.012 0.008 3.348 3.344 7.254 5.762 11.414 7.314 11.378 4.246 24.684 1.826 33.828-7.322l146.746-146.748c9.148-9.148 11.57-22.454 7.324-33.83-1.552-4.16-3.97-8.068-7.314-11.414z",
  'dice': ["M864 192h-512c-88 0-160 72-160 160v512c0 88 72 160 160 160h512c88 0 160-72 160-160v-512c0-88-72-160-160-160zM416 896c-53.020 0-96-42.98-96-96s42.98-96 96-96 96 42.98 96 96-42.98 96-96 96zM416 512c-53.020 0-96-42.98-96-96s42.98-96 96-96 96 42.98 96 96-42.98 96-96 96zM608 704c-53.020 0-96-42.98-96-96s42.98-96 96-96 96 42.98 96 96-42.98 96-96 96zM800 896c-53.020 0-96-42.98-96-96s42.98-96 96-96 96 42.98 96 96-42.98 96-96 96zM800 512c-53.020 0-96-42.98-96-96s42.98-96 96-96 96 42.98 96 96-42.98 96-96 96zM828.76 128c-14.93-72.804-79.71-128-156.76-128h-512c-88 0-160 72-160 160v512c0 77.046 55.196 141.83 128 156.76v-636.76c0-35.2 28.8-64 64-64h636.76z"],
  'dollar': "M480 64c-265.096 0-480 214.904-480 480 0 265.098 214.904 480 480 480 265.098 0 480-214.902 480-480 0-265.096-214.902-480-480-480zM480 928c-212.078 0-384-171.922-384-384s171.922-384 384-384c212.078 0 384 171.922 384 384s-171.922 384-384 384zM512 512v-128h128v-64h-128v-64h-64v64h-128v256h128v128h-128v64h128v64h64v-64h128.002l-0.002-256h-128zM448 512h-64v-128h64v128zM576.002 704h-64.002v-128h64.002v128z",
  'email': "M928 128h-832c-52.8 0-96 43.2-96 96v640c0 52.8 43.2 96 96 96h832c52.8 0 96-43.2 96-96v-640c0-52.8-43.2-96-96-96zM398.74 550.372l-270.74 210.892v-501.642l270.74 290.75zM176.38 256h671.24l-335.62 252-335.62-252zM409.288 561.698l102.712 110.302 102.71-110.302 210.554 270.302h-626.528l210.552-270.302zM625.26 550.372l270.74-290.75v501.642l-270.74-210.892z",
  'time': "M658.744 749.256l-210.744-210.746v-282.51h128v229.49l173.256 173.254zM512 0c-282.77 0-512 229.23-512 512s229.23 512 512 512 512-229.23 512-512-229.23-512-512-512zM512 896c-212.078 0-384-171.922-384-384s171.922-384 384-384c212.078 0 384 171.922 384 384s-171.922 384-384 384z",
  'calendar': "M320 384h128v128h-128zM512 384h128v128h-128zM704 384h128v128h-128zM128 768h128v128h-128zM320 768h128v128h-128zM512 768h128v128h-128zM320 576h128v128h-128zM512 576h128v128h-128zM704 576h128v128h-128zM128 576h128v128h-128zM832 0v64h-128v-64h-448v64h-128v-64h-128v1024h960v-1024h-128zM896 960h-832v-704h832v704z",
  'minus': ["M0 416v192c0 17.672 14.328 32 32 32h960c17.672 0 32-14.328 32-32v-192c0-17.672-14.328-32-32-32h-960c-17.672 0-32 14.328-32 32z"],
  'plus': ["M992 384h-352v-352c0-17.672-14.328-32-32-32h-192c-17.672 0-32 14.328-32 32v352h-352c-17.672 0-32 14.328-32 32v192c0 17.672 14.328 32 32 32h352v352c0 17.672 14.328 32 32 32h192c17.672 0 32-14.328 32-32v-352h352c17.672 0 32-14.328 32-32v-192c0-17.672-14.328-32-32-32z"],
  'save': "M896 0h-896v1024h1024v-896l-128-128zM512 128h128v256h-128v-256zM896 896h-768v-768h64v320h576v-320h74.978l53.022 53.018v714.982z",
  'search': "M992.262 871.396l-242.552-206.294c-25.074-22.566-51.89-32.926-73.552-31.926 57.256-67.068 91.842-154.078 91.842-249.176 0-212.078-171.922-384-384-384-212.076 0-384 171.922-384 384s171.922 384 384 384c95.098 0 182.108-34.586 249.176-91.844-1 21.662 9.36 48.478 31.926 73.552l206.294 242.552c35.322 39.246 93.022 42.554 128.22 7.356s31.892-92.898-7.354-128.22zM384 640c-141.384 0-256-114.616-256-256s114.616-256 256-256 256 114.616 256 256-114.614 256-256 256z",
  'sigma': ["M941.606 734.708l44.394-94.708h38l-64 384h-960v-74.242l331.546-391.212-331.546-331.546v-227h980l44 256h-34.376l-18.72-38.88c-35.318-73.364-61.904-89.12-138.904-89.12h-662l353.056 353.056-297.42 350.944h542.364c116.008 0 146.648-41.578 173.606-97.292z"],
  'list': "M0 0h256v256h-256zM384 64h640v128h-640zM0 384h256v256h-256zM384 448h640v128h-640zM0 768h256v256h-256zM384 832h640v128h-640z",
  'url': ["M440.236 635.766c-13.31 0-26.616-5.076-36.77-15.23-95.134-95.136-95.134-249.934 0-345.070l192-192c46.088-46.086 107.36-71.466 172.534-71.466s126.448 25.38 172.536 71.464c95.132 95.136 95.132 249.934 0 345.070l-87.766 87.766c-20.308 20.308-53.23 20.308-73.54 0-20.306-20.306-20.306-53.232 0-73.54l87.766-87.766c54.584-54.586 54.584-143.404 0-197.99-26.442-26.442-61.6-41.004-98.996-41.004s-72.552 14.562-98.996 41.006l-192 191.998c-54.586 54.586-54.586 143.406 0 197.992 20.308 20.306 20.306 53.232 0 73.54-10.15 10.152-23.462 15.23-36.768 15.23z", "M256 1012c-65.176 0-126.45-25.38-172.534-71.464-95.134-95.136-95.134-249.934 0-345.070l87.764-87.764c20.308-20.306 53.234-20.306 73.54 0 20.308 20.306 20.308 53.232 0 73.54l-87.764 87.764c-54.586 54.586-54.586 143.406 0 197.992 26.44 26.44 61.598 41.002 98.994 41.002s72.552-14.562 98.998-41.006l192-191.998c54.584-54.586 54.584-143.406 0-197.992-20.308-20.308-20.306-53.232 0-73.54 20.306-20.306 53.232-20.306 73.54 0.002 95.132 95.134 95.132 249.932 0.002 345.068l-192.002 192c-46.090 46.088-107.364 71.466-172.538 71.466z"],
  'password': ["M945.942 14.058c-18.746-18.744-49.136-18.744-67.882 0l-202.164 202.164c-51.938-15.754-106.948-24.222-163.896-24.222-223.318 0-416.882 130.042-512 320 41.122 82.124 100.648 153.040 173.022 207.096l-158.962 158.962c-18.746 18.746-18.746 49.136 0 67.882 9.372 9.374 21.656 14.060 33.94 14.060s24.568-4.686 33.942-14.058l864-864c18.744-18.746 18.744-49.138 0-67.884zM416 320c42.24 0 78.082 27.294 90.92 65.196l-121.724 121.724c-37.902-12.838-65.196-48.68-65.196-90.92 0-53.020 42.98-96 96-96zM110.116 512c38.292-60.524 89.274-111.924 149.434-150.296 3.918-2.5 7.876-4.922 11.862-7.3-9.962 27.328-15.412 56.822-15.412 87.596 0 54.89 17.286 105.738 46.7 147.418l-60.924 60.924c-52.446-36.842-97.202-83.882-131.66-138.342z", "M768 442c0-27.166-4.256-53.334-12.102-77.898l-321.808 321.808c24.568 7.842 50.742 12.090 77.91 12.090 141.382 0 256-114.618 256-256z", "M830.026 289.974l-69.362 69.362c1.264 0.786 2.53 1.568 3.786 2.368 60.162 38.374 111.142 89.774 149.434 150.296-38.292 60.522-89.274 111.922-149.436 150.296-75.594 48.218-162.89 73.704-252.448 73.704-38.664 0-76.902-4.76-113.962-14.040l-76.894 76.894c59.718 21.462 123.95 33.146 190.856 33.146 223.31 0 416.876-130.042 512-320-45.022-89.916-112.118-166.396-193.974-222.026z"],
  'ban': "M874.040 149.96c-96.706-96.702-225.28-149.96-362.040-149.96s-265.334 53.258-362.040 149.96c-96.702 96.706-149.96 225.28-149.96 362.040s53.258 265.334 149.96 362.040c96.706 96.702 225.28 149.96 362.040 149.96s265.334-53.258 362.040-149.96c96.702-96.706 149.96-225.28 149.96-362.040s-53.258-265.334-149.96-362.040zM896 512c0 82.814-26.354 159.588-71.112 222.38l-535.266-535.268c62.792-44.758 139.564-71.112 222.378-71.112 211.738 0 384 172.262 384 384zM128 512c0-82.814 26.354-159.586 71.112-222.378l535.27 535.268c-62.794 44.756-139.568 71.11-222.382 71.11-211.738 0-384-172.262-384-384z",
  'file': "M534.626 22.628c-12.444-12.444-37.026-22.628-54.626-22.628h-384c-17.6 0-32 14.4-32 32v960c0 17.6 14.4 32 32 32h768c17.6 0 32-14.4 32-32v-576c0-17.6-10.182-42.182-22.626-54.626l-338.748-338.746zM832 960h-704v-896h351.158c2.916 0.48 8.408 2.754 10.81 4.478l337.556 337.554c1.722 2.402 3.996 7.894 4.476 10.81v543.158zM864 0h-192c-17.6 0-21.818 10.182-9.374 22.626l210.746 210.746c12.446 12.446 22.628 8.228 22.628-9.372v-192c0-17.6-14.4-32-32-32z"
};

/**
 * https://medium.com/@david.gilbertson/icons-as-react-components-de3e33cb8792
 */
var FIcon = _ref => {
  var {
    icon,
    color
  } = _ref;
  if (typeof icon == "string" && icon.length > 0 && Object.keys(library).indexOf(icon) >= 0) return /*#__PURE__*/React.createElement(FIconBase, {
    icon: library[icon],
    color: color
  });
  return icon;
};

var FFormButtons = _ref => {
  var {
    onSave,
    onCancel,
    colors,
    icons,
    labels,
    autoDisable,
    disabled,
    valid,
    elements
  } = _ref;
  var [isSaving, setIsSaving] = useState(false);
  var isMounted = useRef(undefined);
  useEffect(() => {
    isMounted.current = true;
    return () => {
      isMounted.current = false;
    };
  }, []);
  var isDisabled = autoDisable ? !valid : typeof disabled == "function" ? disabled(valid, elements) : disabled;
  var handleSave = ev => {
    setIsSaving(true);
    var result = onSave(ev);
    if (result == Promise.resolve(result)) {
      result.then(_ => {
        if (isMounted.current) {
          setIsSaving(false);
        }
      });
    } else {
      setIsSaving(false);
    }
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-buttons"
  }, onCancel != undefined ? /*#__PURE__*/React.createElement(Button, {
    color: colors ? colors[0] : 'secondary',
    onClick: ev => onCancel(ev)
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: icons[0]
  }), labels ? labels[0] : 'Cancelar') : null, onSave != undefined ? /*#__PURE__*/React.createElement(Button, {
    color: colors ? colors[1] : 'primary',
    onClick: ev => handleSave(ev),
    disabled: isSaving || isDisabled
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: icons[1]
  }), labels ? labels[1] : 'Guardar') : null);
};

var FForm = props => {
  var {
    id,
    children,
    className,
    onSave,
    onCancel,
    colors,
    icons,
    labels,
    autoDisable,
    disabled,
    renderButtons,
    inline,
    getElements
  } = props;
  var {
    ref,
    valid,
    elements
  } = useForm();
  useEffect(() => {
    if (getElements) {
      getElements(valid, elements);
    }
  }, [valid, elements, getElements]);
  return /*#__PURE__*/React.createElement("form", {
    ref: ref,
    id: id,
    className: "formiga-reactstrap-form ".concat(className != undefined ? className : '', " ").concat(inline == true ? 'inline' : ''),
    noValidate: true
  }, /*#__PURE__*/React.createElement(React.Fragment, null, children, renderButtons == undefined ? /*#__PURE__*/React.createElement(FFormButtons, {
    onSave: onSave != undefined ? ev => onSave(valid, elements, ev) : undefined,
    onCancel: onCancel != undefined ? ev => onCancel(valid, elements, ev) : undefined,
    colors: colors,
    icons: icons,
    labels: labels,
    autoDisable: autoDisable,
    disabled: disabled,
    valid: valid,
    elements: elements
  }) : renderButtons(valid, elements)));
};
FForm.propTypes = {
  className: PropTypes.string,
  id: PropTypes.string,
  colors: PropTypes.arrayOf(PropTypes.string),
  icons: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func])),
  labels: PropTypes.arrayOf(PropTypes.string),
  onSave: PropTypes.func,
  onCancel: PropTypes.func,
  autoDisable: PropTypes.bool,
  disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
  renderButtons: PropTypes.func,
  inline: PropTypes.bool,
  getElements: PropTypes.func
};
FForm.defaultProps = {
  icons: ['ban', 'save'],
  autoDisable: true,
  inline: false
};

function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);
  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    enumerableOnly && (symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    })), keys.push.apply(keys, symbols);
  }
  return keys;
}
function _objectSpread2(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = null != arguments[i] ? arguments[i] : {};
    i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
      _defineProperty(target, key, source[key]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
      Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
    });
  }
  return target;
}
function _defineProperty(obj, key, value) {
  key = _toPropertyKey(key);
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return obj;
}
function _toPrimitive(input, hint) {
  if (typeof input !== "object" || input === null) return input;
  var prim = input[Symbol.toPrimitive];
  if (prim !== undefined) {
    var res = prim.call(input, hint || "default");
    if (typeof res !== "object") return res;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
  var key = _toPrimitive(arg, "string");
  return typeof key === "symbol" ? key : String(key);
}

var inputPropTypes = {
  // Props for formiga
  feedback: PropTypes.string,
  checkValue: PropTypes.Promise || PropTypes.func,
  allowedValues: PropTypes.arrayOf(PropTypes.any),
  disallowedValues: PropTypes.arrayOf(PropTypes.any),
  doRepeat: PropTypes.string,
  doNotRepeat: PropTypes.string,
  id: PropTypes.string,
  name: PropTypes.string.isRequired,
  value: function value(props, _propName, _componentName) {
    if (!('value' in props) && !('defaultValue' in props)) {
      return new Error('Please provide a {value} or a {defaultValue}');
    }
  },
  defaultValue: PropTypes.string,
  label: PropTypes.string,
  description: PropTypes.string,
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func, PropTypes.bool]),
  inline: PropTypes.bool,
  readOnly: PropTypes.bool,
  required: PropTypes.bool,
  onChange: PropTypes.func,
  bsSize: PropTypes.oneOf(['', 'lg', 'sm']),
  keepHeight: PropTypes.bool,
  showValidity: PropTypes.oneOf([0, 1, 2, 4]),
  formGroupStyle: PropTypes.object,
  inputGroupStyle: PropTypes.object,
  inputStyle: PropTypes.object
};

var inputDefaultProps = {
  keepHeight: false,
  showValidity: 4,
  inline: false,
  bsSize: undefined
};

var FInputFeedback = _ref => {
  var {
    valid,
    feedback,
    keepHeight
  } = _ref;
  var show = keepHeight || !valid && feedback;
  if (!show) return null;
  return /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-feedback ".concat(valid ? 'hidden' : '')
  }, feedback != undefined && feedback != "" ? feedback : /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0"));
};

var FInputAddon = props => {
  var {
    name,
    value,
    label,
    description,
    feedback,
    icon,
    valid,
    children,
    inline,
    formClassName,
    showValidity,
    keepHeight,
    formGroupStyle,
    inputGroupStyle,
    middleElement,
    bsSize
  } = props;
  var originalValue = useRef(value);
  var [loaded, setLoaded] = useState(false);
  useEffect(() => {
    setLoaded(true);
  }, []);
  var hasChanged = loaded && value != originalValue.current;
  return /*#__PURE__*/React.createElement(FormGroup, {
    className: "formiga-reactstrap-form-group ".concat(hasChanged ? 'is-unsaved' : '', " ").concat(inline === true ? 'inline' : '', " ").concat(formClassName || ''),
    style: formGroupStyle
  }, label != undefined || description != undefined ? /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-label-container"
  }, label != undefined ? /*#__PURE__*/React.createElement(Label, {
    for: name,
    className: "formiga-reactstrap-label"
  }, label) : null, description != undefined ? /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-description"
  }, description) : null) : null, /*#__PURE__*/React.createElement(InputGroup, {
    style: inputGroupStyle,
    size: bsSize,
    className: bsSize ? "input-group-".concat(bsSize) : ''
  }, icon === false ? null : /*#__PURE__*/React.createElement("span", {
    className: "input-group-prepend"
  }, /*#__PURE__*/React.createElement(InputGroupText, {
    className: "input-group-addon"
  }, icon == undefined ? '' : /*#__PURE__*/React.createElement(FIcon, {
    icon: icon
  }))), children), middleElement != undefined ? middleElement : null, (keepHeight === true || feedback != undefined) && showValidity >= 2 ? /*#__PURE__*/React.createElement(FInputFeedback, {
    valid: valid,
    feedback: feedback,
    keepHeight: keepHeight
  }) : null);
};

var isControlled = props => {
  return Object.keys(props).indexOf('defaultValue') < 0;
};

var withWrapControlled = function withWrapControlled(BaseComponent) {
  var defGetter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  var _parseDef = v => {
    if (defGetter == undefined) {
      return v;
    }
    if (v != undefined) {
      return v;
    }
    return defGetter(v);
  };
  var _withWrapControlled = props => {
    var {
      value,
      defaultValue,
      onChange
    } = props;
    var controlledRef = useRef(isControlled(props));
    var initialValueRef = useRef(isControlled(props) ? value : defaultValue);
    var [innerValue, setInnerValue] = useState(_parseDef(isControlled(props) ? value : defaultValue));
    useEffect(() => {
      var nInnerValue = controlledRef.current ? value : defaultValue;
      setInnerValue(_parseDef(nInnerValue));
    }, [value, defaultValue]);
    var setValue = useCallback((newValue, confirmed, event) => {
      setInnerValue(_parseDef(newValue));
      if (onChange != undefined) {
        onChange(newValue, confirmed, event);
      }
    }, [onChange]);
    return /*#__PURE__*/React.createElement(BaseComponent, Object.assign({}, props, {
      initialValue: initialValueRef.current,
      value: innerValue,
      setValue: setValue
    }));
  };
  return _withWrapControlled;
};

var _makeId = (id, name) => {
  return id != undefined ? id : name != undefined ? "formiga-reactstrap-checkbox-".concat(name) : "unique_value_here_please";
};
var _FInputCheckbox = props => {
  var {
    value,
    setValue,
    inputStyle,
    bsSize,
    showValidity,
    readOnly,
    required,
    id,
    name,
    checkboxLabel
  } = props;
  var input = useInput(_objectSpread2({}, props));
  var [inputId, setInputId] = useState(_makeId(id, name));
  useEffect(() => {
    setInputId(_makeId(id, name));
  }, [id, name]);
  var handleChange = useCallback(event => {
    var nValue = event.target.checked;
    setValue(nValue, true, event);
  }, [setValue]);
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement("div", {
    className: "custom-switch custom-control "
    /* better styling on the div, it is not very useful on the input here */,
    style: inputStyle
  }, /*#__PURE__*/React.createElement("input", {
    type: "checkbox",
    id: inputId,
    name: name,
    className: "custom-control ".concat(bsSize != undefined ? 'custom-control-' + bsSize : '', " custom-control-input ").concat(showValidity == 1 || showValidity == 4 ? input.valid ? 'is-valid' : 'is-invalid' : ''),
    ref: input.ref,
    disabled: readOnly != undefined ? readOnly : false,
    required: required,
    checked: value,
    onChange: handleChange
  }), /*#__PURE__*/React.createElement("label", {
    className: "custom-control-label",
    htmlFor: inputId
  }, checkboxLabel)));
};
var FInputCheckbox = withWrapControlled(_FInputCheckbox);
FInputCheckbox.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  checkboxLabel: PropTypes.string
});
FInputCheckbox.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'checkmark'
});

var FInputCheckbox2 = props => {
  var style = {
    /*width: "calc(100% - 2.6em)",*/
    minWidth: "70px",
    border: "1px solid #c2cfd6",
    left: "0",
    paddingTop: "0.2em",
    paddingLeft: "3.5em"
  };
  if ((props === null || props === void 0 ? void 0 : props.bsSize) == 'lg') {
    style.height = '48px';
    style.paddingTop = '0.75em';
  }
  return /*#__PURE__*/React.createElement(FInputCheckbox, _objectSpread2(_objectSpread2({}, props), {}, {
    formGroupStyle: {
      verticalAlign: "middle"
    },
    inputStyle: style,
    checkboxLabel: undefined,
    icon: props.icon === false ? props.icon : props.checkboxLabel
  }));
};
FInputCheckbox2.propTypes = FInputCheckbox.propTypes;
FInputCheckbox2.defaultProps = _objectSpread2({}, FInputCheckbox.defaultProps);

var _FInputColor = props => {
  var {
    id,
    name,
    placeholder,
    readOnly,
    required,
    autocomplete,
    inputStyle,
    showValidity,
    bsSize,
    value,
    setValue
  } = props;
  var input = useInput(_objectSpread2({}, props));
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: input.valid,
    invalid: !input.valid
  } : {};
  var handleChange = useCallback(event => {
    var newValue = event.target.value;
    setValue(newValue, false, event);
  }, [setValue]);
  var handleInput = useCallback(event => {
    var newValue = event.target.value;
    setValue(newValue, true, event);
  }, [setValue]);
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement(Input, Object.assign({
    id: id,
    name: name,
    innerRef: input.ref,
    type: "color",
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    required: required,
    autoComplete: autocomplete,
    style: inputStyle,
    bsSize: bsSize,
    value: value,
    onChange: handleChange,
    onInput: handleInput
  }, showValidProps)));
};
var FInputColor = withWrapControlled(_FInputColor);
FInputColor.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  autocomplete: PropTypes.oneOf(["on", "off"])
});
FInputColor.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'color'
});

var _formatInnerValue = function _formatInnerValue(isoString) {
  var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
  var dateFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "DD/MM/YYYY";
  var date = isoString ? new Date(isoString) : null;
  if (!date) {
    return '';
  }
  var month = date.getMonth() + 1;
  var day = date.getDate();
  if (dateFormat.match(/MM.DD.YYYY/)) {
    return (month > 9 ? month : "0".concat(month)) + separator + (day > 9 ? day : "0".concat(day)) + separator + date.getFullYear();
  } else if (dateFormat.match(/DD.MM.YYYY/)) {
    return (day > 9 ? day : "0".concat(day)) + separator + (month > 9 ? month : "0".concat(month)) + separator + date.getFullYear();
  } else {
    return date.getFullYear() + separator + (month > 9 ? month : "0".concat(month)) + separator + (day > 9 ? day : "0".concat(day));
  }
};
var FInputDateBase = props => {
  var {
    id,
    name,
    placeholder,
    readOnly,
    autocomplete,
    inputGroupStyle,
    required,
    inputStyle,
    onChange,
    transform,
    showValidity,
    bsSize
  } = props;
  var controlled = isControlled(props);
  var {
    value,
    defaultValue
  } = props;
  var [innerValue, setInnerValue] = useState(controlled ? transform.toISO(value) : transform.toISO(defaultValue));
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    transformValue: transform.fromISO,
    checkValue: props.checkValue != undefined ? v => props.checkValue(transform.fromISO(v)) : undefined
  }));
  useEffect(() => {
    var nInnerValue = controlled ? transform.toISO(value) : transform.toISO(defaultValue);
    //if (innerValue != nInnerValue) {
    setInnerValue(nInnerValue);
    //}
    input.setValue(_formatInnerValue(nInnerValue));
    input.validate();
  }, [/*innerValue,*/value, defaultValue, controlled, transform, input]);
  var handleChange = (value, formattedValue) => {
    setInnerValue(value);
    input.setValue(formattedValue || '');
    input.validate();
    if (onChange != undefined) {
      // TODO Ask RDP to expose event as a onChange() parameter,
      // so we can expose it here too
      onChange(transform.fromISO(value), true, undefined);
    }
  };
  var nInputGroupStyle = _objectSpread2(_objectSpread2({}, inputGroupStyle), {}, {
    flexWrap: "unset"
  });
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: input.valid,
    invalid: !input.valid
  } : {};
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback,
    inputGroupStyle: nInputGroupStyle
  }), /*#__PURE__*/React.createElement(DatePicker, Object.assign({
    id: id,
    name: name,
    weekStartsOn: 1,
    placeholder: placeholder,
    inputRef: input.ref,
    dateFormat: "DD/MM/YYYY",
    disabled: readOnly,
    required: required,
    autocomplete: autocomplete,
    className: showValidity == 1 || showValidity == 4 ? input.valid ? 'is-valid' : 'is-invalid' : '',
    style: inputStyle,
    value: innerValue,
    onChange: (v, f) => handleChange(v || undefined, f),
    size: bsSize,
    clearButtonElement: /*#__PURE__*/React.createElement(FIcon, {
      icon: "cross"
    })
  }, showValidProps)));
};
FInputDateBase.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  placeholder: PropTypes.string,
  autocomplete: PropTypes.oneOf(["on", "off"]),
  transform: PropTypes.object
});
FInputDateBase.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'calendar',
  inputStyle: {} // invalidate the r-d-p width default
});

var isoToDate = value => {
  if (value === undefined || value === '') {
    return value;
  }
  var getDateFromEu = s => {
    var parts = s.split('/');
    var year = parseInt(parts[2]);
    var month = parseInt(parts[1]) - 1;
    var day = parseInt(parts[0]);
    return [day, month, year];
  };
  var getDateFromIso = s => {
    var parts = s.split('-');
    var year = parseInt(parts[0]);
    var month = parseInt(parts[1]) - 1;
    var day = parseInt(parts[2]);
    return [day, month, year];
  };

  // date
  var day, month, year;
  if (value.indexOf('/') >= 0) {
    [day, month, year] = getDateFromEu(value);
  } else {
    [day, month, year] = getDateFromIso(value);
  }

  // time
  var hour = 0,
    min = 0,
    secs = 0;
  if (value.indexOf('T') >= 0) {
    var parts = value.split('T')[1];
    parts = parts.split(':');
    hour = parseInt(parts[0]);
    min = parseInt(parts[1]);
    secs = parseInt(parts[2]);
  }
  var date = new Date(Date.UTC(year, month, day, hour, min, secs));
  return date;
};

var strToISO$1 = value => {
  if (typeof value == 'string' && value.length > 0) {
    /*
    if (value=='today') {
      const today= new Date()
      const date= new Date(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()))
      return date.toISOString()
    }
    */

    var date = isoToDate(value);
    if (date == undefined || date == '') {
      return '';
    }
    return date.toISOString();
  }
  return undefined;
};
var strFromISO$1 = value => {
  var pad = n => n.toString().padStart(2, '0');
  var date = isoToDate(value);
  if (date == undefined || date == '') {
    return '';
  }
  var day = date.getDate();
  var month = date.getMonth() + 1;
  var year = date.getFullYear();
  return "".concat(pad(day), "/").concat(pad(month), "/").concat(year);
};
var FInputDate = props => {
  return /*#__PURE__*/React.createElement(FInputDateBase, _objectSpread2(_objectSpread2({}, props), {}, {
    transform: {
      fromISO: strFromISO$1,
      toISO: strToISO$1
    }
  }));
};
FInputDate.propTypes = _objectSpread2(_objectSpread2({}, FInputDateBase.propTypes), {}, {
  value: PropTypes.string
});
FInputDate.defaultProps = _objectSpread2({}, FInputDateBase.defaultProps);

var strToISO = value => {
  if (typeof value == 'string' && value.length > 0) {
    /*
    if (value=='today') {
      const today= new Date()
      const date= new Date(Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()))
      return date.toISOString()
    }
    */

    var date = isoToDate(value);
    if (date == undefined || date == '') {
      // console.log('strToISO value='+value+' => no date')
      return '';
    }
    // console.log('strToISO value='+value+' => '+date.toISOString())

    return date.toISOString();
  }
  // console.log('strToISO value='+value+' => undefined')
  return undefined;
};
var strFromISO = value => {
  //const pad = (n) => n.toString().padStart(2, '0')

  var date = isoToDate(value);
  if (date == undefined || date == '') {
    // console.log('strFromISO value='+value+' => no date')
    return '';
  }

  // console.log('strFromISO value='+value+' => '+date.toISOString())

  return date.toISOString();

  //  const day= date.getDate()
  //  const month= date.getMonth()+1
  //  const year= date.getFullYear()
  //
  //  return `${pad(day)}/${pad(month)}/${year}`
};

var FInputDateIso = props => {
  return /*#__PURE__*/React.createElement(FInputDateBase, _objectSpread2(_objectSpread2({}, props), {}, {
    transform: {
      fromISO: strFromISO,
      toISO: strToISO
    }
  }));
};
FInputDateIso.propTypes = _objectSpread2(_objectSpread2({}, FInputDateBase.propTypes), {}, {
  value: PropTypes.string
});
FInputDateIso.defaultProps = _objectSpread2({}, FInputDateBase.defaultProps);

var dateAdjustOffset = (d, f) => {
  var offs = d.getTimezoneOffset() * f;
  var msecs = offs * 60 * 1000;
  d.setTime(d.getTime() + msecs);
  return d;
};
var unixToISO = value => {
  if (!value || isNaN(value)) {
    return undefined;
  }
  var date = new Date(value * 1000);
  date = dateAdjustOffset(date, -1);
  return date.toISOString();
};
var unixFromISO = value => {
  if (!value) {
    return undefined;
  }
  var date = dateAdjustOffset(isoToDate(value), 1);
  var usecs = Math.floor(date.getTime() / 1000);
  return usecs;
};
var FInputEpoch = props => {
  return /*#__PURE__*/React.createElement(FInputDateBase, _objectSpread2(_objectSpread2({}, props), {}, {
    transform: {
      fromISO: unixFromISO,
      toISO: unixToISO
    }
  }));
};
FInputEpoch.propTypes = _objectSpread2(_objectSpread2({}, FInputDateBase.propTypes), {}, {
  value: PropTypes.number
});
FInputEpoch.defaultProps = _objectSpread2({}, FInputDateBase.defaultProps);

var FITClear = props => {
  var {
    value,
    readOnly,
    onClear
  } = props;
  var is_clearable = value != '' && value != undefined && !readOnly;
  return /*#__PURE__*/React.createElement(InputGroupText, {
    onClick: ev => {
      is_clearable ? onClear(ev) : null;
    },
    style: {
      cursor: is_clearable ? 'pointer' : 'not-allowed',
      opacity: is_clearable ? 1 : 0.5
    }
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "cross"
  }));
};

var _FInputTime = props => {
  var {
    id,
    name,
    placeholder,
    readOnly,
    required,
    step,
    min,
    max,
    autocomplete,
    inputStyle,
    showValidity,
    bsSize,
    value,
    setValue
  } = props;
  var input = useInput(_objectSpread2({}, props));
  var handleChange = useCallback(event => {
    var newValue = event.target.value;
    setValue(newValue, true, event);
  }, [setValue]);
  var handleClear = useCallback(event => {
    setValue(undefined, true, event);
  }, [setValue]);
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: input.valid,
    invalid: !input.valid
  } : {};
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement(Input, Object.assign({
    id: id,
    name: name,
    innerRef: input.ref,
    type: "time",
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    required: required,
    autoComplete: autocomplete,
    style: inputStyle,
    bsSize: bsSize,
    value: value,
    onChange: handleChange,
    step: step,
    min: min,
    max: max
  }, showValidProps)), /*#__PURE__*/React.createElement(FITClear, Object.assign({}, props, {
    onClear: handleClear
  })));
};
var FInputTime = withWrapControlled(_FInputTime, v => v || '');
FInputTime.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  placeholder: PropTypes.string,
  autocomplete: PropTypes.oneOf(["on", "off"]),
  max: PropTypes.string,
  min: PropTypes.string,
  step: PropTypes.number,
  clearable: PropTypes.bool
});
FInputTime.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'time',
  step: 60
});

var ProgressBar = _ref => {
  var {
    progress,
    ftypeIcon,
    bsSize
  } = _ref;
  var prg = progress != undefined ? progress : 0;
  var col = progress == 100 ? '#00e64d' : '#ffcc00';
  return /*#__PURE__*/React.createElement("div", {
    className: "bars formiga-reactstrap-progress",
    style: {
      position: "relative",
      width: ftypeIcon == undefined ? "100%" : bsSize == 'sm' ? "calc(100% - 75px)" : bsSize == 'lg' ? "calc(100% - 92px)" : "calc(100% - 83px)",
      left: ftypeIcon != undefined ? bsSize == 'sm' ? "35px" : bsSize == 'lg' ? "51px" : "42px" : "",
      top: "-3px",
      zIndex: "5"
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: "progress-xs  mb-0 progress",
    style: {
      height: "0.25em",
      backgroundColor: "transparent"
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: "progress-bar bg-" + col,
    style: {
      width: prg + "%",
      backgroundColor: col
    },
    role: "progressbar",
    "aria-valuenow": prg.toString(),
    "aria-valuemin": "0",
    "aria-valuemax": "100"
  })));
};

var _getIcon = (mtype, icon, iconMap) => {
  if (icon == undefined || icon === false) {
    return undefined;
  }
  if (iconMap) {
    var i1 = iconMap[mtype];
    if (i1) {
      return i1;
    }
  }
  if (icon) {
    return icon;
  }
  return 'file';
};
var useFileTypeIcon = (mtype, icon, iconMap) => {
  var [theIcon, setTheIcon] = useState(_getIcon(mtype, icon, iconMap));
  useEffect(() => {
    setTheIcon(_getIcon(mtype, icon, iconMap));
  }, [mtype, icon, iconMap]);
  return theIcon;
};

var FFHidden = props => {
  var {
    id,
    name,
    readOnly,
    required,
    accept,
    bsSize,
    onChange,
    hasValue,
    inputRef
  } = props;
  return /*#__PURE__*/React.createElement("input", {
    style: {
      zIndex: "0",
      display: "inline",
      opacity: "0",
      visibility: "hidden"
    },
    id: id,
    name: name
    // Do not lose the form-control class
    // TODO maybe open PR on reactstrap?
    ,
    className: "form-control ".concat(bsSize != undefined ? 'form-control-' + bsSize : ''),
    ref: inputRef,
    type: "file"
    //value       = {undefined}
    ,
    onChange: onChange,
    readOnly: readOnly != undefined ? readOnly : false
    // If we receive some value on initing,
    // we have no way to assign it to this input (file are readonly)
    // So we hack this.
    // TODO Would be better to use maybe another type of hidden input,
    // keeping the <file> just for the file upload.
    ,
    required: required && !hasValue
    //valid       = {valid ? 'true' : 'false'}
    //invalid     = {!valid ? 'true' : 'false'}
    ,
    accept: accept
  });
};

var useValidClassnames = (valid, showValidity, customCheck) => {
  var [cname, setCname] = useState('');
  useEffect(() => {
    var nCname = '';
    if (showValidity == 1 || showValidity == 4) {
      var custom = true;
      if (customCheck != undefined) {
        custom = customCheck();
      }
      if (!custom || !valid) {
        nCname = 'is-invalid';
      } else {
        nCname = 'is-valid';
      }
    }
    setCname(nCname);
  }, [valid, showValidity, customCheck]);
  return [cname];
};

var formatBytes = function formatBytes(bytes) {
  var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
  if (bytes === 0) return '0 Bytes';
  var k = 1024;
  var dm = decimals < 0 ? 0 : decimals;
  var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  var i = Math.floor(Math.log(bytes) / Math.log(k));
  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
};

var FFInput = props => {
  var {
    required,
    inputStyle,
    showValidity,
    bsSize,
    statusMsg,
    hasValue,
    value,
    valid,
    ftypeIcon,
    onDownload,
    onBrowse
  } = props;
  var [className] = useValidClassnames(valid, showValidity, () => hasValue || !required);
  return /*#__PURE__*/React.createElement("div", {
    style: _objectSpread2({
      opacity: "1",
      zIndex: "3",
      position: "absolute",
      width: ftypeIcon == undefined ? "100%" : bsSize == 'sm' ? "calc(100% - 74px)" : bsSize == 'lg' ? "calc(100% - 91px)" : "calc(100% - 82px)",
      left: ftypeIcon != undefined ? bsSize == 'sm' ? "35px" : bsSize == 'lg' ? "51px" : "42px" : "",
      display: "flex",
      cursor: 'pointer',
      userSelect: 'none'
    }, inputStyle),
    className: "form-control ".concat(className, " ").concat(bsSize != undefined ? 'form-control-' + bsSize : ''),
    onClick: hasValue ? ev => onDownload(ev) : _ => onBrowse()
  }, hasValue ? /*#__PURE__*/React.createElement("div", {
    style: {
      display: "flex",
      width: "100%",
      alignItems: "stretch"
    }
  }, /*#__PURE__*/React.createElement("div", {
    style: {
      whiteSpace: "nowrap",
      overflow: "hidden",
      textOverflow: "ellipsis"
    }
  }, "".concat(onDownload != undefined ? '⤓ ' : '').concat(value.name)), /*#__PURE__*/React.createElement("div", {
    style: {
      flex: "1 1 auto",
      textAlign: "right"
    }
  }, /*#__PURE__*/React.createElement("i", {
    style: {
      fontSize: "0.6em",
      opacity: "0.75",
      whiteSpace: "nowrap"
    }
  }, " (".concat(formatBytes(value.size), ")")))) : statusMsg != undefined ? statusMsg : '...');
};

var FFClear = _ref => {
  var {
    hasValue,
    onClear
  } = _ref;
  return /*#__PURE__*/React.createElement(InputGroupText, {
    onClick: hasValue ? ev => onClear(ev) : () => {},
    style: {
      cursor: hasValue ? 'pointer' : 'not-allowed',
      zIndex: "2",
      opacity: hasValue ? 1 : 0.5
    }
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "cross"
  }));
};

var _FInputFile = props => {
  var {
    icon,
    onDownload,
    iconMap,
    value,
    setValue
  } = props;
  var input = useInput(_objectSpread2({}, props));
  var [hasValue, setHasValue] = useState((value === null || value === void 0 ? void 0 : value.buffer) || (value === null || value === void 0 ? void 0 : value.size) > 0);
  var [progress, setProgress] = useState(undefined);
  var [status, setStatus] = useState(undefined);
  var [statusMsg, setStatusMsg] = useState(undefined);
  var ftypeIcon = useFileTypeIcon(value === null || value === void 0 ? void 0 : value.type, icon, iconMap);
  useEffect(() => {
    if (value) {
      if (value.buffer == undefined || value.buffer.length == 0) {
        if (value.size > 0) {
          input.setValidity('');
        }
      }
    }
  }, [value, input]);
  var handleChange = useCallback(event => {
    event.persist();
    try {
      var reader = new FileReader();
      reader.onerror = e => {
        var st_msg = '';
        switch (e.target.error.code) {
          case e.target.error.NOT_FOUND_ERR:
            st_msg = 'File not found!';
            break;
          case e.target.error.NOT_READABLE_ERR:
            st_msg = 'Unreadable file';
            break;
          case e.target.error.ABORT_ERR:
            break;
          // noop
          default:
            st_msg = 'Error reading file';
        }
        setStatusMsg(st_msg);
        setStatus('error');
        setValue({}, true, event);
        setHasValue(false);
      };
      reader.onabort = _e => {
        setStatus('abort');
        setStatusMsg('Aborted');
        setProgress(undefined);
        setValue({}, true, event);
        setHasValue(false);
      };
      reader.onprogress = e => {
        // e is an ProgressEvent.
        if (e.lengthComputable) {
          setProgress(Math.round(e.loaded / e.total * 100));
        }
      };
      reader.onloadstart = _e => {
        setProgress(0);
        setStatus('uploading');
        setStatusMsg('Loading file');
      };
      reader.onload = e => {
        var file = event.target.files[0];
        setProgress(100);
        setStatusMsg('File loaded');
        var nValue = {
          name: file.name,
          size: file.size,
          type: file.type,
          buffer: new Uint8Array(e.target.result)
        };
        setValue(nValue, true, e);
        setHasValue(true);

        //input.setValue(file)
        input.validate();
      };
      reader.readAsArrayBuffer(event.target.files[0]);
    } catch (e) {
      console.error(e);
      setStatus(undefined);
      setStatusMsg(undefined);
      setHasValue(false);
    }
  }, [setValue, input]);
  var handleClear = useCallback(event => {
    setProgress(0);
    setStatus(undefined);
    setStatusMsg(undefined);
    setValue({}, true, event);
    setHasValue(false);
    input.validate();
  }, [setValue, input]);
  var handleBrowse = useCallback(() => {
    //let evt = document.createEvent("MouseEvents")
    //evt.initEvent("click", true, false)     
    //input.node.dispatchEvent(evt)
    //input.dispatchEvent('click', {cancelable: false})
    input.node.click();
  }, [input]);
  var handleDownload = useCallback(ev => {
    if (onDownload != undefined) {
      onDownload(value, ev);
    }
  }, [value, onDownload]);

  // console.log(`status ${status} - vname ${value?.name} - files ${input?.node?.files.length} · ${ input?.node?.files[0]?.name}`)

  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback,
    icon: ftypeIcon,
    middleElement: status != undefined ? /*#__PURE__*/React.createElement(ProgressBar, {
      progress: progress,
      ftypeIcon: ftypeIcon,
      bsSize: props.bsSize
    }) : null
  }), /*#__PURE__*/React.createElement(FFHidden, Object.assign({}, props, {
    onChange: handleChange,
    hasValue: hasValue,
    inputRef: input.ref
  })), /*#__PURE__*/React.createElement(FFInput, Object.assign({}, props, {
    statusMsg: statusMsg,
    hasValue: hasValue,
    value: value,
    valid: input.valid,
    onDownload: handleDownload,
    onBrowse: handleBrowse,
    ftypeIcon: ftypeIcon
  })), /*#__PURE__*/React.createElement(FFClear, {
    hasValue: hasValue,
    onClear: handleClear
  }));
};
var FInputFile = withWrapControlled(_FInputFile);
FInputFile.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  onDownload: PropTypes.func,
  accept: PropTypes.string,
  iconMap: PropTypes.object
});
FInputFile.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'file',
  value: undefined
});

var isNotNumber = n => n === '' || n === undefined || n === null || isNaN(n);

var _getStepOrDecimals = (step, decimals) => {
  if (step != undefined) {
    if (!isNaN(step)) {
      return step;
    }
  }
  if (decimals != undefined) {
    if (!isNaN(decimals)) {
      return 1 / Math.pow(10, decimals);
    }
  }
  return undefined;
};
var useStepOrDecimals = (step, decimals) => {
  var [nStep, setNStep] = useState(_getStepOrDecimals(step, decimals));
  useEffect(() => {
    setNStep(_getStepOrDecimals(step, decimals));
  }, [step, decimals]);
  return nStep;
};

var FFSHidden = props => {
  var {
    id,
    name,
    required,
    inputRef,
    defaultValue
  } = props;
  return /*#__PURE__*/React.createElement("input", {
    type: "text",
    id: id,
    name: name,
    ref: inputRef,
    style: {
      display: "none"
    },
    required: required,
    defaultValue: defaultValue
  });
};

var FLT_FLOAT_EN = /^-?\d*[.]?\d*$/;
var FLT_FLOAT_ES = /^-?\d*[,]?\d*$/;
var FLT_FLOAT_BOTH = /^-?\d*[,.]?\d*$/;

var _checkFloat$1 = s => {
  var n = s == undefined ? '' : s.toString().replace(/,/g, '.');
  if (isNotNumber(n)) {
    return false;
  }
  return true;
};
var _checkFloatList = l => {
  if (l == undefined || l == '' || l.length == 0) {
    return false;
  }
  var valid = true;
  for (var s of l) {
    if (!_checkFloat$1(s)) {
      valid = false;
      break;
    }
  }
  return valid;
};
var toFloat = s => {
  if (!_checkFloat$1(s)) {
    //console.log(`toFloat ${typeof s} ${s} => 0.0 (not float)`)

    return 0.0;
  }
  return parseFloat(s.toString().replace(/,/g, '.'));
};
var toFloatList = l => {
  if (!_checkFloatList(l)) {
    return [0.0];
  }
  return l.map(s => toFloat(s));
};
var fromFloat = (f, decimalSign, forceSign) => {
  if (isNotNumber(f)) {
    //console.log(`fromFloat ${typeof f} ${f} => "" (not number)`)
    return '';
  }
  var n = parseFloat(f);
  var s = n.toString().replace('.', decimalSign);
  if (forceSign === false && n == 0) {
    s = "-".concat(s);
  }

  //console.log(`fromFloat ${f} => ${s}`)

  return s;
};
var sumFloatList = l => {
  var fls = toFloatList(l);
  //console.log(fls)
  var sum = fls.reduce((a, b) => a + b, 0);
  return sum;
};

var roundFloat = (number, decimals) => {
  var factorOfTen = Math.pow(10, decimals);
  var rounded = Math.round(number * factorOfTen) / factorOfTen;
  //console.log(`roundFloat ${number} ==> ${rounded}`)
  return rounded;
};

var countDecimals = f => {
  try {
    var s = parseFloat(f).toString();
    if (s.indexOf('e-') > 0) {
      return parseInt(s.split('-')[1]);
    }
    return f.toString().split('.')[1].length;
  } catch (e) {
    return 0;
  }
};

var _startsWithTrashZero = s => {
  if (!s) {
    return false;
  }
  if (s.length < 2) {
    return false;
  }
  var firstIdx = s.slice(0, 1) == '-' ? 1 : 0;
  if (s.slice(firstIdx, firstIdx + 1) != '0') {
    return false;
  }
  var nextIdx = firstIdx + 1;
  if (isNaN(s.slice(nextIdx, nextIdx + 1))) {
    return false;
  }
  return true;
};
var FFSInput = _ref => {
  var {
    className,
    placeholder,
    readOnly,
    valid,
    autocomplete,
    inputStyle,
    stepOrDecimals,
    focusIt,
    showValidity,
    bsSize,
    sign,
    value,
    onChange,
    onAddValue,
    onRemValue,
    isLastOne,
    removable,
    decimalSign
  } = _ref;
  var reprRef = useRef(undefined);
  useInputFilter(reprRef === null || reprRef === void 0 ? void 0 : reprRef.current, FLT_FLOAT_BOTH);
  var [innerRepr, setInnerRepr] = useState(fromFloat(value, decimalSign, sign));
  useEffect(() => {
    if (focusIt) {
      reprRef.current.focus();
    }
  }, [focusIt]);
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: valid,
    invalid: !valid
  } : {};
  var incrValue = useCallback((factor, confirmed) => {
    var curValue = toFloat(value);
    var incr = stepOrDecimals != undefined ? parseFloat(stepOrDecimals) : 1.00;
    var nValue = roundFloat(curValue + parseFloat(factor) * incr, countDecimals(stepOrDecimals));
    var nRepr = fromFloat(nValue, decimalSign, sign);

    //console.log(`incrValue() current ${typeof curValue} ${curValue} + incr ${typeof incr} ${incr} => ${typeof nValue} ${nValue} (repr: ${typeof nRepr} ${nRepr})`)

    setInnerRepr(nRepr);
    onChange(nValue, confirmed);
  }, [value, onChange, stepOrDecimals, sign, decimalSign]);
  var getInnerReprFromEvent = useCallback(event => {
    var nRepr = event.target.value;
    //console.log(`${innerRepr} ==> ${nRepr}`)
    if (nRepr != '' && innerRepr == '-0' && nRepr.indexOf('-') < 0) {
      nRepr = "-".concat(nRepr);
    }
    if (_startsWithTrashZero(nRepr)) {
      nRepr = nRepr.replace('0', '');
    }
    return nRepr;
  }, [innerRepr]);
  var handleChange = useCallback(event => {
    var nRepr = getInnerReprFromEvent(event);
    setInnerRepr(nRepr);
    var nValue = toFloat(nRepr);
    onChange(nValue, false);
  }, [onChange, getInnerReprFromEvent]);
  var handleKeyDown = useCallback(event => {
    // Simulate natives number input up/down
    if (event.key == 'ArrowUp' || event.key == 'ArrowDown') {
      event.preventDefault();
      var factor = event.key == 'ArrowUp' ? 1 : -1;
      incrValue(factor, false);
      return;
    }

    // Only allow to add new fields if we are in the last input
    if (event.key == '+' || event.key == '-') {
      if (isLastOne) {
        // // If value is positive and key is '-' and we are at the inputs beginning,
        // // means "change input's sign" instead of "add new"
        // let changeSign= false
        // if (event.key=='-' && event.target.value!='') {
        //   const f= parseFloat(event.target.value)
        //   if (f>0) {
        //     if (event.target.selectionStart==0) {
        //       changeSign= true
        //     }
        //   }
        // }
        // if (! changeSign) {
        var lastRepr = innerRepr.slice(-1)[0];
        if (lastRepr != '' && lastRepr != ',' && lastRepr != '.') {
          event.preventDefault();
          if (event.key == '+') {
            onAddValue(true);
          } else {
            onAddValue(false);
          }
        }
        //}
      }
    }

    if (event.key == 'Backspace' && event.target.value.length <= 1 && removable) {
      event.preventDefault();
      onRemValue();
    }
  }, [innerRepr, incrValue, isLastOne, onAddValue, onRemValue, removable]);
  var handleBlur = useCallback(event => {
    var nRepr = getInnerReprFromEvent(event);
    var nValue = toFloat(nRepr);
    onChange(nValue, true);
  }, [onChange, getInnerReprFromEvent]);
  return /*#__PURE__*/React.createElement(Input, Object.assign({
    className: className,
    type: "text",
    innerRef: reprRef,
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    autoComplete: autocomplete,
    style: inputStyle,
    size: Math.max(innerRepr.length || 0, 2),
    value: innerRepr,
    onChange: handleChange,
    onKeyDown: handleKeyDown,
    onBlur: handleBlur,
    bsSize: bsSize,
    step: stepOrDecimals
  }, showValidProps));
};

var getInnerSum = (summed, value) => {
  if (summed == undefined || value == undefined || value.length == 0) {
    return 0;
  }
  // Round sum to the max number of decimals
  var decs = value.map(f => countDecimals(f));
  var maxd = Math.max(...decs);
  return summed.toFixed(maxd);
};
var getInnerSumRepr = (innerSum, decimalSign) => {
  return innerSum.toString().replace('.', decimalSign);
};
var FFSTotal = _ref => {
  var {
    value,
    decimalSign
  } = _ref;
  var [innerSum, setInnerSum] = useState(getInnerSum(sumFloatList(value), value));
  var [innerSumRepr, setInnerSumRepr] = useState(getInnerSumRepr(innerSum, decimalSign));
  useEffect(() => {
    var nInnerSum = getInnerSum(sumFloatList(value), value);
    setInnerSum(nInnerSum);
    setInnerSumRepr(getInnerSumRepr(nInnerSum, decimalSign));
  }, [value, decimalSign]);
  return /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-float-sum-total"
  }, isNaN(innerSum) ? '' : innerSumRepr);
};

var withWrapControlledForArray = function withWrapControlledForArray(BaseComponent) {
  var eventName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'onBlur';
  var _withWrapControlledForArray = props => {
    var controlled = isControlled(props);
    var {
      value,
      defaultValue,
      onChange
    } = props;
    var initialValue = useRef(controlled ? value : defaultValue);
    var [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
    useEffect(() => {
      var nInnerValue = controlled ? value : defaultValue;
      setInnerValue(nInnerValue);
    }, [value, defaultValue, controlled]);
    var setValue = useCallback((newValue, confirmed, event) => {
      //console.log('withWrapControlledForArray.setValue ' + newValue)
      setInnerValue(newValue);
      if (onChange != undefined) {
        onChange(newValue, confirmed, event);
      }
    }, [setInnerValue, onChange]);
    var handleChange = useCallback(event => {
      //console.log('withWrapControlledForArray.handleChange')
      var newValue = event.target.value;
      setValue(newValue, false, event);
    }, [setValue]);
    var handleBlur = useCallback(event => {
      //console.log('withWrapControlledForArray.handleBlur')
      var newValue = event.target.value;
      setValue(newValue, true, event);
    }, [setValue]);

    //console.log(`withWrapControlledForArray value ${value} defValue ${defaultValue} innerValue ${innerValue}`)

    return /*#__PURE__*/React.createElement(BaseComponent, Object.assign({}, props, {
      initialValue: initialValue.current,
      value: Array.isArray(innerValue) ? innerValue : [],
      setValue: setValue,
      onChange: handleChange
    }, {
      [eventName]: handleBlur
    }));
  };
  return _withWrapControlledForArray;
};

var _getInputSigns = value => {
  if (value == undefined || value.length == 0) {
    return [];
  }
  return value.map(v => isNotNumber(v) ? true : v >= 0);
};
var _FInputFloatSum = props => {
  var {
    id,
    name,
    value,
    setValue,
    placeholder,
    readOnly,
    step,
    decimals,
    decimalSign,
    autocomplete,
    inputStyle,
    showValidity,
    bsSize
  } = props;
  var stepOrDecimals = useStepOrDecimals(step, decimals);
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    // TODO
    // wrap this checks (as we save array in the hidden input):
    //      min, max, stepOrDecimals,
    //checkValue: (v) => true

    // transformValue,
    // allowedValues, 
    // disallowedValues, 
    // doRepeat, 
    // doNotRepeat, 
    // feedback
    decimals: undefined,
    inputFilter: undefined
  }));
  var [inputSigns, setInputsSigns] = useState(_getInputSigns(value));
  var [inputWithFocus, setInputWithFocus] = useState(0);
  useEffect(() => {
    input.setValue(value);
    input.validate();
  }, [input, value]);

  // Add a new input and focus it
  // innerRepr must be handled in paralell
  var handleAddValue = useCallback(pos => {
    var nValue = [...value];
    nValue.push(0.0);
    var nSigns = [...inputSigns];
    nSigns.push(pos);
    setValue(nValue, false);
    setInputsSigns(nSigns);
    setInputWithFocus(nValue.length - 1);
  }, [value, setValue, inputSigns]);

  // Remove an input's value and its repr
  // innerRepr must be handled in paralell  
  var handleRemValue = useCallback(iIndex => {
    var nValue = value != undefined ? [...value] : [0.0];
    nValue.splice(iIndex, 1);
    setValue(nValue, true);
    var nSigns = [...inputSigns];
    nSigns.splice(iIndex, 1);
    setInputsSigns(nSigns);
    setInputWithFocus(Math.max(iIndex - 1, 0));
  }, [value, setValue, inputSigns]);

  // Update an input's value and its repr
  // innerRepr must be handled in paralell
  var handleChange = useCallback((tValue, confirmed, iIndex) => {
    var nValue = [...value];
    if (nValue.length > iIndex) {
      nValue[iIndex] = tValue;
    } else {
      nValue.push(tValue);
    }
    setValue(nValue, confirmed);
  }, [value, setValue]);
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-float-sum"
  }, /*#__PURE__*/React.createElement(FFSHidden, Object.assign({}, props, {
    inputRef: input.ref,
    defaultValue: value
  })), value.map((iValue, iIndex) => {
    var sign = inputSigns[iIndex];
    return /*#__PURE__*/React.createElement("div", {
      className: "formiga-reactstrap-float-sum-box ".concat(sign ? 'positive' : 'negative'),
      key: "formiga-reactstrap-float-sum-".concat(id || name, "-repr-").concat(iIndex)
    }, /*#__PURE__*/React.createElement(FFSInput, {
      className: "formiga-reactstrap-float-sum-input",
      placeholder: placeholder || "",
      readOnly: readOnly != undefined ? readOnly : false,
      valid: input.valid,
      showValidity: showValidity,
      autocomplete: autocomplete,
      inputStyle: inputStyle,
      stepOrDecimals: stepOrDecimals,
      focusIt: inputWithFocus == iIndex,
      bsSize: bsSize,
      value: iValue,
      sign: sign,
      decimalSign: decimalSign,
      onChange: (v, c) => handleChange(v, c, iIndex),
      onAddValue: pos => handleAddValue(pos),
      onRemValue: () => handleRemValue(iIndex),
      isLastOne: iIndex == value.length - 1,
      removable: value.length > 1
    }));
  }), /*#__PURE__*/React.createElement(FFSTotal, {
    value: value,
    decimalSign: decimalSign
  })));
};
var FInputFloatSum = withWrapControlledForArray(_FInputFloatSum);
FInputFloatSum.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  value: function value(props, _propName, _componentName) {
    if (!('value' in props) && !('defaultValue' in props)) {
      return new Error('Please provide a {value} or a {defaultValue}');
    }
  },
  defaultValue: PropTypes.arrayOf(PropTypes.number),
  placeholder: PropTypes.string,
  max: PropTypes.number,
  min: PropTypes.number,
  step: PropTypes.number,
  decimals: PropTypes.number,
  decimalSign: PropTypes.oneOf([',', '.']),
  autocomplete: PropTypes.oneOf(["on", "off"])
});
FInputFloatSum.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: "sigma",
  decimals: undefined,
  decimalSign: '.'
});

var wrappedCheckValue = (props, value) => {
  if (props.checkValue != undefined) {
    if (!props.checkValue(value)) {
      return false;
    }
  }
  if (props.gt != undefined) {
    if (value <= props.gt) {
      return false;
    }
  }
  if (props.lt != undefined) {
    if (value >= props.lt) {
      return false;
    }
  }
  return true;
};
var _FInputNumber = props => {
  var {
    value,
    setValue,
    id,
    name,
    placeholder,
    readOnly,
    required,
    min,
    max,
    step,
    decimals,
    autocomplete,
    t,
    inputFilter,
    inputStyle,
    showArrows,
    showValidity,
    bsSize
  } = props;
  var reprRef = useRef(undefined);
  var [innerRepr, setInnerRepr] = useState(t.from(value));
  var stepOrDecimals = useStepOrDecimals(step, decimals);
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    checkValue: v => wrappedCheckValue(props, t.to(v))
  }));
  useInputFilter(reprRef === null || reprRef === void 0 ? void 0 : reprRef.current, inputFilter);
  var incrValue = useCallback((factor, confirmed) => {
    var curValue = isNotNumber(value) ? 0.0 : parseFloat(value);
    var incr = stepOrDecimals != undefined ? parseFloat(stepOrDecimals) : 1.00;
    var nValue = roundFloat(curValue + parseFloat(factor) * incr, countDecimals(stepOrDecimals));
    var nRepr = t.from(nValue);

    //console.log(`incrValue() current ${typeof curValue} ${curValue} + incr ${typeof incr} ${incr} => ${typeof nValue} ${nValue} (repr: ${typeof nRepr} ${nRepr})`)

    setValue(nValue, confirmed);
    input.setValue(nValue);
    input.validate();
    setInnerRepr(nRepr);
  }, [value, setValue, stepOrDecimals, t, input]);
  var handleChange = useCallback(event => {
    var nRepr = event.target.value;
    var nValue = t.to(nRepr);

    //console.log(`handleChange() => ${typeof nValue} ${nValue} (repr: ${typeof nRepr} ${nRepr})`)

    setValue(nValue, false, event);
    input.setValue(nValue);
    input.validate();
    setInnerRepr(nRepr);
  }, [setValue, t, input]);
  var handleKeyDown = useCallback(event => {
    if (event.key == 'ArrowUp' || event.key == 'ArrowDown') {
      event.preventDefault();
      var factor = event.key == 'ArrowUp' ? 1 : -1;
      incrValue(factor, false);
    }
  }, [incrValue]);
  var handleBlur = useCallback(event => {
    var nRepr = event.target.value;
    var nValue = t.to(nRepr);
    setValue(nValue, true, event);
  }, [setValue, t]);
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: input.valid,
    invalid: !input.valid
  } : {};

  //console.log(`FInputNumber => value ${value} repr ${innerRepr}`)

  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement("input", {
    type: "number",
    id: id,
    name: name,
    ref: input.ref,
    style: {
      display: "none"
    },
    required: required,
    max: max,
    min: min,
    step: stepOrDecimals,
    defaultValue: value
  }), /*#__PURE__*/React.createElement(Input, Object.assign({
    type: "text",
    innerRef: reprRef,
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    autoComplete: autocomplete,
    style: inputStyle,
    onKeyDown: ev => handleKeyDown(ev),
    value: innerRepr,
    onChange: handleChange,
    onBlur: handleBlur,
    bsSize: bsSize
  }, showValidProps)), showArrows ? /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-input-number-addon ".concat(readOnly ? 'read-only' : '')
  }, /*#__PURE__*/React.createElement(InputGroupText, {
    className: "formiga-reactstrap-input-number-incr",
    onClick: () => incrValue(-1, true)
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "minus"
  })), /*#__PURE__*/React.createElement(InputGroupText, {
    className: "formiga-reactstrap-input-number-incr",
    onClick: () => incrValue(1, true)
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "plus"
  }))) : null);
};
var FInputNumber = withWrapControlled(_FInputNumber);
FInputNumber.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  defaultValue: PropTypes.number,
  placeholder: PropTypes.string,
  max: PropTypes.number,
  min: PropTypes.number,
  step: PropTypes.number,
  decimals: PropTypes.number,
  gt: PropTypes.number,
  lt: PropTypes.number,
  autocomplete: PropTypes.oneOf(["on", "off"]),
  showArrows: PropTypes.bool
});
FInputNumber.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  showArrows: true
});

var _checkFloat = s => {
  var n = s == undefined ? '' : s.toString().replace(/,/g, '.');
  if (isNotNumber(n)) {
    return false;
  }
  return true;
};
var useFloatProps = decimalSign => {
  var toFloat = s => {
    if (!_checkFloat(s)) {
      //console.log(`toFloat ${typeof s} ${s} => 0.0 (not float)`)

      return 0.0;
    }
    return parseFloat(s.toString().replace(/,/g, '.'));
  };
  var fromFloat = f => {
    if (isNotNumber(f)) {
      //console.log(`fromFloat ${typeof f} ${f} => "" (not number)`)
      return '';
    }
    var s = parseFloat(f).toString().replace('.', decimalSign);

    //console.log(`fromFloat ${f} => ${s}`)

    return s;
  };
  var t = {
    from: fromFloat,
    to: toFloat
  };
  return t;
};

var FInputFloat = props => {
  var t = useFloatProps(props.decimalSign);
  return /*#__PURE__*/React.createElement(FInputNumber, _objectSpread2(_objectSpread2({}, props), {}, {
    inputFilter: props.decimalSign == ',' ? FLT_FLOAT_ES : FLT_FLOAT_EN,
    t
  }));
};
FInputFloat.propTypes = _objectSpread2(_objectSpread2({}, FInputNumber.propTypes), {}, {
  decimals: PropTypes.number,
  decimalSign: PropTypes.oneOf([',', '.'])
});
FInputFloat.defaultProps = _objectSpread2(_objectSpread2({}, FInputNumber.defaultProps), {}, {
  icon: 'dollar',
  decimals: undefined,
  decimalSign: '.'
});

var _checkInt = s => {
  var n = s == undefined ? '' : s.toString().replace(/,/g, '.');
  if (isNotNumber(n)) {
    return false;
  }
  return true;
};
var useIntProps = () => {
  var toInt = s => {
    if (!_checkInt(s)) {
      //console.log(`toInt ${typeof s} [${s}] => 0 (not int)`)
      return 0;
    }
    return parseInt(s.toString().replace(/,/g, '.'));
  };
  var fromInt = f => {
    if (isNotNumber(f)) {
      //console.log(`fromInt ${typeof f} [${f}] => "" (not number)`)
      return '';
    }
    var s = parseInt(f).toString();
    return s;
  };
  var t = {
    from: fromInt,
    to: toInt
  };
  return t;
};

var FInputInt = props => {
  var t = useIntProps();
  return /*#__PURE__*/React.createElement(FInputNumber, _objectSpread2(_objectSpread2({}, props), {}, {
    inputFilter: 'int',
    t
  }));
};
FInputInt.propTypes = FInputNumber.propTypes;
FInputInt.defaultProps = _objectSpread2(_objectSpread2({}, FInputNumber.defaultProps), {}, {
  icon: 'dice'
});

var FInputUInt = props => {
  var t = useIntProps();
  return /*#__PURE__*/React.createElement(FInputNumber, _objectSpread2(_objectSpread2({}, props), {}, {
    inputFilter: 'uint',
    t
  }));
};
FInputUInt.propTypes = FInputNumber.propTypes;
FInputUInt.defaultProps = _objectSpread2(_objectSpread2({}, FInputNumber.defaultProps), {}, {
  icon: 'dice'
});

/*

  NOTE

  If provided options is a simple object, remember that keys will be always treated as strings.
  This Note should be on the Select component docs!

*/

var useEnabledOptions = (options, allowedValues, disallowedValues) => {
  var [enabledOptions, setEnabledOptions] = useState([]);
  useEffect(() => {
    var getFromArrayOfArray = a => {
      var enabledOptions = [];
      a.map(opt => {
        var optValue = opt[0];
        var optLabel = opt[1] || optValue;
        var optDisabled = opt.length >= 3 ? opt[2] : false;
        enabledOptions.push({
          value: optValue,
          label: optLabel,
          disabled: optDisabled
        });
      });
      return enabledOptions;
    };
    var getFromArrayOfObject = a => {
      var enabledOptions = [];
      a.map(opt => {
        var optValue = opt.value;
        var optLabel = (opt === null || opt === void 0 ? void 0 : opt.label) || optValue;
        var optDisabled = (opt === null || opt === void 0 ? void 0 : opt.disabled) || false;
        enabledOptions.push({
          value: optValue,
          label: optLabel,
          disabled: optDisabled
        });
      });
      return enabledOptions;
    };
    var getFromObject = a => {
      var enabledOptions = [];
      Object.entries(a).map(opt => {
        var optValue = opt[0];
        var optLabel = opt[1];
        enabledOptions.push({
          value: optValue,
          label: optLabel,
          disabled: false
        });
      });
      return enabledOptions;
    };
    var isAnArray = v => Object.prototype.toString.call(v) === '[object Array]';
    var isDisallowed = v => {
      if (disallowedValues) {
        if (disallowedValues.indexOf(v) >= 0) {
          return true;
        }
      }
      return false;
    };
    var isAllowed = v => {
      if (allowedValues) {
        if (allowedValues.indexOf(v) >= 0) {
          return true;
        }
        return false;
      }
      return true;
    };
    var optionsList = [];
    if (!isAnArray(options)) {
      if (Object.keys(options).length > 0) {
        optionsList = getFromObject(options);
      }
    } else {
      if (options.length > 0) {
        var first = options[0];
        if (isAnArray(first)) {
          optionsList = getFromArrayOfArray(options);
        } else {
          optionsList = getFromArrayOfObject(options);
        }
      }
    }
    var nEnabledOptions = optionsList.map(opt => {
      return {
        value: opt.value,
        label: opt.label,
        disabled: opt.disabled || isDisallowed(opt.value) || !isAllowed(opt.value)
      };
    });
    setEnabledOptions(nEnabledOptions);
  }, [options, allowedValues, disallowedValues]);
  return enabledOptions;
};

var parseValueDependOnOptions = (v, options) => {
  var iValue = v;

  // check if is Numeric and convert
  if (!isNaN(iValue)) {
    var optVals = options.map(o => o.value);
    if (optVals.indexOf(iValue) < 0) {
      if (optVals.indexOf(parseFloat(iValue)) >= 0) {
        iValue = parseFloat(iValue);
      } else if (optVals.indexOf(parseInt(iValue)) >= 0) {
        iValue = parseInt(iValue);
      }
    }
  }
  return iValue;
};

var FISClear = props => {
  var {
    value,
    readOnly,
    onClear
  } = props;
  var is_clearable = value != '' && value != undefined && !readOnly;
  return /*#__PURE__*/React.createElement(InputGroupText, {
    onClick: ev => {
      is_clearable ? onClear(ev) : null;
    },
    style: {
      cursor: is_clearable ? 'pointer' : 'not-allowed',
      opacity: is_clearable ? 1 : 0.5
    }
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "cross"
  }));
};

var makeId = obj => {
  if (!obj) {
    return '';
  }
  return JSON.stringify(obj).substr(0, 50);
};

var FISInput = props => {
  var {
    id,
    name,
    placeholder,
    readOnly,
    autocomplete,
    required,
    options,
    inputStyle,
    clearable,
    showValidity,
    bsSize,
    value,
    valid,
    inputRef,
    onInputChange,
    enabledOptions
  } = props;
  var className = "custom-select ".concat(bsSize != undefined ? 'custom-select-' + bsSize : '', " ").concat(useValidClassnames(valid, showValidity));
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: valid,
    invalid: !valid
  } : {};
  return /*#__PURE__*/React.createElement(Input, Object.assign({
    id: id || makeId(options),
    name: name,
    type: "select",
    className: className,
    innerRef: inputRef,
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    required: required,
    autoComplete: autocomplete,
    style: inputStyle,
    value: value,
    bsSize: bsSize,
    onChange: onInputChange
  }, showValidProps), clearable && enabledOptions.filter(opt => opt.value == '').length == 0 ? /*#__PURE__*/React.createElement("option", {
    key: "".concat(name, "_option_empty"),
    value: ''
  }, '') : null, enabledOptions.map(opt => /*#__PURE__*/React.createElement("option", Object.assign({
    key: "".concat(name, "_option_").concat(opt.value),
    value: opt.value
  }, opt.disabled ? {
    disabled: true
  } : {}), opt.label)), clearable ? /*#__PURE__*/React.createElement("option", {
    style: {
      display: "none"
    },
    value: ""
  }) : null);
};

var _FInputSelect = props => {
  var {
    setValue,
    allowedValues,
    disallowedValues,
    options,
    clearable
  } = props;
  var enabledOptions = useEnabledOptions(options, allowedValues, disallowedValues);
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    checkValue: props.checkValue != undefined ? v => props.checkValue(parseValueDependOnOptions(v, enabledOptions)) : undefined
  }));
  var updValue = useCallback((nValue, confirm, event) => {
    var iValue = parseValueDependOnOptions(nValue, enabledOptions);
    setValue(iValue, confirm, event);
    input.setValue(iValue);
    input.validate();
  }, [input, enabledOptions, setValue]);
  var handleChange = useCallback(event => {
    updValue(event.target.value, true, event);
  }, [updValue]);
  var handleClear = useCallback(event => {
    updValue('', true, event);
  }, [updValue]);
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement(FISInput, Object.assign({}, props, {
    valid: input.valid,
    inputRef: input.ref,
    onInputChange: handleChange,
    enabledOptions: enabledOptions
  })), clearable !== false ? /*#__PURE__*/React.createElement(FISClear, Object.assign({}, props, {
    onClear: handleClear
  })) : null);
};
var FInputSelect = withWrapControlled(_FInputSelect, v => v || '');
FInputSelect.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  placeholder: PropTypes.string,
  options: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.array)]),
  autocomplete: PropTypes.oneOf(["on", "off"]),
  clearable: PropTypes.bool
});
FInputSelect.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'list',
  clearable: true
});

var FISMInput = props => {
  var {
    id,
    name,
    placeholder,
    readOnly,
    autocomplete,
    required,
    inputStyle,
    bsSize,
    showValidity,
    value,
    valid,
    inputRef,
    onInputChange,
    enabledOptions,
    theSize
  } = props;
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: valid,
    invalid: !valid
  } : {};
  var forceStyle = showValidity == 1 || showValidity == 4 ? {
    backgroundImage: valid ? "url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e\")" : "url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e\")",
    backgroundSize: "calc(0.75em + 0.375rem) calc(0.75em + 0.375rem)"
  } : {};
  return /*#__PURE__*/React.createElement(Input, Object.assign({
    id: id,
    name: name,
    type: "select",
    className: "custom-select ".concat(bsSize != undefined ? 'custom-select-' + bsSize : ''),
    multiple: true,
    innerRef: inputRef,
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    required: required,
    autoComplete: autocomplete,
    style: _objectSpread2(_objectSpread2({}, inputStyle), forceStyle),
    bsSize: bsSize,
    size: theSize,
    value: value,
    onChange: onInputChange
  }, showValidProps), enabledOptions.map(opt => /*#__PURE__*/React.createElement("option", {
    key: "".concat(name, "_option_").concat(opt.value),
    value: opt.value,
    disabled: opt.disabled
  }, opt.label)));
};

var _getSize = (size, value, options) => {
  if (typeof size == 'function') {
    try {
      return size(value, options);
    } catch (e) {
      console.error(e);
    }
  }
  if (!isNaN(size)) {
    return parseInt(size);
  }
  if (Array.isArray(options)) {
    return options.length;
  }
  try {
    return Object.keys(options).length;
  } catch (e) {
    console.error(e);
  }
  return 2;
};
var useSize = (size, value, options) => {
  var [theSize, setTheSize] = useState(_getSize(size, value, options));
  useEffect(() => {
    setTheSize(_getSize(size, value, options));
  }, [size, value, options]);
  return theSize;
};

var FISMClear = props => {
  var {
    value,
    readOnly,
    onClear
  } = props;
  var is_clearable = value != undefined && value.length > 0 && !readOnly;
  return /*#__PURE__*/React.createElement(InputGroupText, {
    onClick: ev => {
      is_clearable ? onClear(ev) : null;
    },
    style: {
      cursor: is_clearable ? 'pointer' : 'not-allowed',
      opacity: is_clearable ? 1 : 0.5
    }
  }, /*#__PURE__*/React.createElement(FIcon, {
    icon: "cross"
  }));
};

var numOrArrayToString = v => {
  if (Array.isArray(v)) {
    return v.map(a => isNaN(a) ? '' : a.toString());
  }
  return isNaN(v) ? '' : v.toString();
};
var _FInputSelectMultiple = props => {
  var {
    allowedValues,
    disallowedValues,
    options,
    size,
    clearable,
    value,
    setValue
  } = props;
  var enabledOptions = useEnabledOptions(options, allowedValues, disallowedValues);
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    checkValue: props.checkValue != undefined ? value => props.checkValue(value.map(v => parseValueDependOnOptions(v, enabledOptions))) : undefined
  }));
  var theSize = useSize(size, value, options);
  var handleChange = useCallback(ev => {
    var value = Array.prototype.slice.call(ev.target.options).filter(opt => opt.selected).map(opt => parseValueDependOnOptions(opt.value, enabledOptions));
    setValue(numOrArrayToString(value), true, ev);
    input.validate();
  }, [setValue, enabledOptions, input]);
  var handleClear = useCallback(event => {
    setValue([], true, event);
  }, [setValue]);
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement(FISMInput, Object.assign({}, props, {
    valid: input.valid,
    inputRef: input.ref,
    onInputChange: handleChange,
    enabledOptions: enabledOptions,
    theSize: theSize
  })), clearable !== false ? /*#__PURE__*/React.createElement(FISMClear, Object.assign({}, props, {
    onClear: handleClear
  })) : null);
};
var FInputSelectMultiple = withWrapControlled(_FInputSelectMultiple);
FInputSelectMultiple.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  placeholder: PropTypes.string,
  options: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.array)]),
  autocomplete: PropTypes.oneOf(["on", "off"]),
  clearable: PropTypes.bool,
  size: PropTypes.oneOfType([PropTypes.func, PropTypes.number])
});
FInputSelectMultiple.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'list',
  clearable: true,
  size: (v, opts) => Array.isArray(opts) ? opts.length : 0
});

var FISSHidden = props => {
  var {
    id,
    name,
    required,
    value,
    inputRef
  } = props;
  return /*#__PURE__*/React.createElement(Input, {
    id: id,
    name: name,
    className: "formiga-reactstrap-select-search-hidden",
    type: "hidden",
    innerRef: inputRef,
    required: required,
    defaultValue: value
  });
};

var FISSInput = props => {
  var {
    name,
    placeholder,
    readOnly,
    autocomplete,
    required,
    inputStyle,
    showValidity,
    bsSize,
    valid,
    filterRef,
    shownText,
    onSearchStart,
    onSearchType,
    onKeyDown
  } = props;
  return /*#__PURE__*/React.createElement(Input, Object.assign({
    name: "input_select_search_".concat(name, "_text"),
    className: "formiga-reactstrap-select-search-text custom-select ".concat(bsSize != undefined ? 'custom-select-' + bsSize : ''),
    type: "text",
    innerRef: filterRef,
    value: shownText,
    placeholder: placeholder,
    readOnly: readOnly,
    required: required,
    onClick: onSearchStart,
    onChange: onSearchType,
    onKeyDown: onKeyDown,
    autoComplete: autocomplete,
    style: inputStyle,
    bsSize: bsSize
  }, showValidity == 1 || showValidity == 4 ? {
    valid: valid,
    invalid: !valid
  } : {}));
};

var FISSAction = props => {
  var {
    readOnly,
    clearable,
    value,
    creating,
    onCreate,
    onClear
  } = props;
  var is_clearable = value != '' && value != undefined && !readOnly;
  if (creating) {
    return /*#__PURE__*/React.createElement(InputGroupText, {
      onClick: ev => onCreate(ev),
      style: {
        cursor: 'pointer'
      }
    }, /*#__PURE__*/React.createElement(FIcon, {
      icon: "plus",
      color: "#28a745"
    }));
  }
  if (clearable) {
    return /*#__PURE__*/React.createElement(InputGroupText, {
      onClick: ev => {
        is_clearable ? onClear(ev) : null;
      },
      style: {
        cursor: is_clearable ? 'pointer' : 'not-allowed',
        opacity: is_clearable ? 1 : 0.5
      }
    }, /*#__PURE__*/React.createElement(FIcon, {
      icon: "cross"
    }));
  }
  return null;
};

var FISSList = props => {
  var {
    name,
    maxShownOptions,
    listRef,
    optionsMap,
    onSelect,
    optActive
  } = props;
  var getListStyle = () => {
    // TODO
    // Check where this gap (13 / 6) comes from and try to make better
    /*if (filterRef.current) {  
      return {
        left: filterRef.current.parentNode.children[0].offsetWidth+13+'px',
        minWidth: filterRef.current.offsetWidth+'px',
        maxWidth: filterRef.current.offsetWidth+'px'
      }
    }*/
    return {};
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-select-search-list list-group shadow-lg",
    ref: listRef,
    style: getListStyle()
  }, optionsMap.map((opt, idx) => {
    if (idx <= maxShownOptions - 1) {
      return /*#__PURE__*/React.createElement("div", {
        key: "".concat(name, "_option_").concat(opt.value),
        value: opt.value,
        className: "formiga-reactstrap-select-search-list-item list-group-item list-group-item-action ".concat(opt.disabled ? 'disabled' : '', " ").concat(optActive == idx ? 'active' : ''),
        onClick: ev => !opt.disabled && onSelect(opt.value, ev)
      }, opt.label || /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0"));
    }
  }), optionsMap.length > maxShownOptions ? /*#__PURE__*/React.createElement("div", {
    key: "".concat(name, "_option_ellipsis"),
    className: "formiga-reactstrap-select-search-list-item list-group-item list-group-item-action disabled ellipsis"
  }, "...") : null);
};

var getOptionsLabel = (options, value) => {
  var elOpt = options.find(opt => opt.value == value);
  return (elOpt === null || elOpt === void 0 ? void 0 : elOpt.label) || '';
};
var _FInputSelectSearch = props => {
  var {
    options,
    feedback,
    allowedValues,
    disallowedValues,
    keepHeight,
    creatable,
    onCreate,
    value,
    setValue
  } = props;
  var wrapperRef = useRef(undefined);
  var filterRef = useRef(undefined);
  var listRef = useRef(undefined);
  var [isOpen, setIsOpen] = useState(false);
  var [optionsMap, setOptionsMap] = useState([]);
  var [optActive, setOptActive] = useState(undefined);
  var [shownText, setShownText] = useState('');
  var [creating, setCreating] = useState(false);
  var enabledOptions = useEnabledOptions(options, allowedValues, disallowedValues);
  var input = useInput(_objectSpread2(_objectSpread2({}, props), {}, {
    checkValue: props.checkValue != undefined ? v => props.checkValue(parseValueDependOnOptions(v, enabledOptions)) : undefined
  }));
  useEffect(() => {
    var onClickOutside = event => {
      if (wrapperRef && wrapperRef.current && !wrapperRef.current.contains(event.target)) {
        if (listRef && listRef.current && !listRef.current.contains(event.target)) {
          handleSearchAbort(event);
        }
      }
    };
    document.addEventListener('mousedown', onClickOutside);
    return () => {
      document.removeEventListener('mousedown', onClickOutside);
    };
  });
  useEffect(() => {
    var nShownText = getOptionsLabel(enabledOptions, value);
    setShownText(nShownText);
  }, [enabledOptions, value]);
  useEffect(() => {
    var sfilter = shownText ? shownText.toLowerCase() : '';
    var nOptionsMap = enabledOptions.filter(opt => sfilter.length > 0 ? opt.label.toLowerCase().includes(sfilter) : true);
    setOptionsMap(nOptionsMap);
    if (shownText.length > 0 && creatable) {
      if (nOptionsMap.length == 0) {
        setCreating(true);
      }
    }
  }, [shownText, enabledOptions, creatable]);
  var handleChange = useCallback((tValue, event) => {
    var nValue = parseValueDependOnOptions(tValue, enabledOptions);
    setValue(nValue, true, event);
    input.setValue(nValue);
    var nShownText = getOptionsLabel(enabledOptions, tValue);
    setShownText(nShownText);
    input.validate();
  }, [input, setValue, enabledOptions]);
  var handleSearchStart = useCallback(_event => {
    if (!isOpen) {
      setIsOpen(true);
    }
    setOptActive(undefined);
  }, [isOpen]);
  var handleSearchType = useCallback(event => {
    setShownText(event.target.value);
    handleSearchStart(event);
  }, [handleSearchStart]);
  var handleSearchAbort = useCallback(event => {
    setIsOpen(false);
    setOptActive(undefined);
    if (shownText == '') {
      handleChange('', event);
    }
  }, [shownText, handleChange]);
  var handleSelect = useCallback((newValue, event) => {
    setIsOpen(false);
    setOptActive(undefined);
    handleChange(newValue, event);
  }, [handleChange]);
  var handleClear = useCallback(event => {
    setIsOpen(true);
    setOptActive(undefined);
    handleChange('', event);
  }, [handleChange]);
  var handleKeyDown = useCallback(event => {
    if (event.key == 'ArrowUp' || event.key == 'ArrowDown') {
      event.preventDefault();
      if (isOpen) {
        if (optionsMap.length > 0) {
          var factor = event.key == 'ArrowUp' ? -1 : 1;
          var nOptActive = optActive == undefined ? 0 : optActive + factor;
          setOptActive(nOptActive);
        }
      }
    }
    if (event.key == 'Enter') {
      event.preventDefault();
      if (isOpen) {
        if (optionsMap.length > 0) {
          if (optActive != undefined) {
            var opt = optionsMap[optActive];
            if ((opt === null || opt === void 0 ? void 0 : opt.disabled) !== true) {
              var nValue = opt.value;
              handleSelect(nValue, event);
            }
          }
        }
      }
    }
    return true;
  }, [isOpen, optActive, optionsMap, handleSelect]);
  var handleCreate = useCallback(event => {
    if (onCreate != undefined) {
      onCreate(shownText, event);
    }
    setCreating(false);
  }, [shownText, onCreate]);
  return /*#__PURE__*/React.createElement("div", {
    className: "formiga-reactstrap-select-search",
    ref: wrapperRef
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: isOpen ? undefined : feedback || input.feedback,
    keepHeight: isOpen ? false : keepHeight
  }), /*#__PURE__*/React.createElement(FISSHidden, Object.assign({}, props, {
    inputRef: input.ref
  })), /*#__PURE__*/React.createElement(FISSInput, Object.assign({}, props, {
    valid: input.valid,
    filterRef: filterRef,
    shownText: shownText,
    onSearchStart: handleSearchStart,
    onSearchType: handleSearchType,
    onKeyDown: handleKeyDown
  })), /*#__PURE__*/React.createElement(FISSAction, Object.assign({}, props, {
    creating: creating,
    onCreate: handleCreate,
    onClear: handleClear
  })))), isOpen ? /*#__PURE__*/React.createElement(FISSList, Object.assign({}, props, {
    listRef: listRef,
    optionsMap: optionsMap,
    onSelect: handleSelect,
    optActive: optActive
  })) : null);
};
var FInputSelectSearch = withWrapControlled(_FInputSelectSearch);
FInputSelectSearch.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  placeholder: PropTypes.string,
  options: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.array)]),
  autocomplete: PropTypes.oneOf(["on", "off"]),
  clearable: PropTypes.bool,
  creatable: PropTypes.bool,
  onCreate: PropTypes.func,
  maxShownOptions: PropTypes.number
});
FInputSelectSearch.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'search',
  maxShownOptions: 10
});

var _FInputText = props => {
  var {
    id,
    name,
    inputType,
    maxLength,
    minLength,
    placeholder,
    readOnly,
    required,
    autocomplete,
    inputStyle,
    showValidity,
    bsSize,
    value,
    setValue
  } = props;
  var input = useInput(_objectSpread2({}, props));
  var handleChange = useCallback(event => {
    var newValue = event.target.value;
    setValue(newValue, false, event);
  }, [setValue]);
  var handleBlur = useCallback(event => {
    var newValue = event.target.value;
    setValue(newValue, true, event);
  }, [setValue]);
  var showValidProps = showValidity == 1 || showValidity == 4 ? {
    valid: input.valid,
    invalid: !input.valid
  } : {};
  return /*#__PURE__*/React.createElement(FInputAddon, Object.assign({}, props, {
    valid: input.valid,
    invalid: !input.valid,
    feedback: input.feedback
  }), /*#__PURE__*/React.createElement(Input, Object.assign({
    id: id,
    name: name,
    innerRef: input.ref,
    type: inputType || "text",
    placeholder: placeholder || "",
    readOnly: readOnly != undefined ? readOnly : false,
    required: required,
    maxLength: maxLength,
    minLength: minLength,
    autoComplete: autocomplete,
    style: inputStyle,
    bsSize: bsSize,
    value: value,
    onChange: handleChange,
    onBlur: handleBlur
  }, showValidProps)));
};
var FInputText = withWrapControlled(_FInputText, v => v || '');
FInputText.propTypes = _objectSpread2(_objectSpread2({}, inputPropTypes), {}, {
  inputType: PropTypes.string,
  placeholder: PropTypes.string,
  maxLength: PropTypes.number,
  minLength: PropTypes.number,
  inputFilter: PropTypes.oneOfType([PropTypes.func, PropTypes.instanceOf(RegExp), PropTypes.string]),
  autocomplete: PropTypes.oneOf(["on", "off"])
});
FInputText.defaultProps = _objectSpread2(_objectSpread2({}, inputDefaultProps), {}, {
  icon: 'text',
  inputType: 'text',
  placeholder: ''
});

var FInputEmail = props => /*#__PURE__*/React.createElement(FInputText, Object.assign({}, props, {
  inputType: "email"
}));
FInputEmail.propTypes = FInputText.propTypes;
delete FInputEmail.propTypes['inputType'];
FInputEmail.defaultProps = _objectSpread2(_objectSpread2({}, FInputText.defaultProps), {}, {
  icon: 'email',
  label: 'E-Mail'
});

/*
https://justmarkup.com/articles/2012-12-28-input-url/
*/

var FInputUrl = props => /*#__PURE__*/React.createElement(FInputText, Object.assign({}, props, {
  inputType: "text"
}));
FInputUrl.propTypes = FInputText.propTypes;
delete FInputUrl.propTypes['inputType'];
FInputUrl.defaultProps = _objectSpread2(_objectSpread2({}, FInputText.defaultProps), {}, {
  icon: 'url',
  label: 'URL',
  pattern: "^(https?://)?([a-zA-Z0-9]([a-zA-ZäöüÄÖÜ0-9-]{0,61}[a-zA-Z0-9])?.)+[a-zA-Z/]{2,6}$"
});

var FInputPassword = props => /*#__PURE__*/React.createElement(FInputText, Object.assign({}, props, {
  inputType: "password"
}));
FInputPassword.propTypes = FInputText.propTypes;
delete FInputPassword.propTypes['inputType'];
FInputPassword.defaultProps = _objectSpread2(_objectSpread2({}, FInputText.defaultProps), {}, {
  icon: 'password',
  label: 'Password'
});

var FInputTextArea = props => /*#__PURE__*/React.createElement(FInputText, Object.assign({}, props, {
  inputType: "textarea"
}));
FInputTextArea.propTypes = FInputText.propTypes;
delete FInputTextArea.propTypes['inputType'];
FInputTextArea.defaultProps = _objectSpread2(_objectSpread2({}, FInputText.defaultProps), {}, {
  icon: 'text'
});

export { FForm, FInputCheckbox, FInputCheckbox2, FInputColor, FInputDate, FInputDateIso, FInputEmail, FInputEpoch, FInputFile, FInputFloat, FInputFloatSum, FInputInt, FInputPassword, FInputSelect, FInputSelectMultiple, FInputSelectSearch, FInputText, FInputTextArea, FInputTime, FInputUInt, FInputUrl };
//# sourceMappingURL=formiga-reactstrap.mjs.map
