import e from"react";import t from"../../prop-types/index.js";import n from"../../classnames/index.js";import{tagPropType as r,warnOnce as o,mapToCssModules as i}from"./utils.js";function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}var f=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a.apply(this,arguments)}function s(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}(this,n)}}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}var d={children:t.node,type:t.string,size:t.oneOfType([t.number,t.string]),bsSize:t.string,valid:t.bool,invalid:t.bool,tag:r,innerRef:t.oneOfType([t.object,t.func,t.string]),plaintext:t.bool,addon:t.bool,className:t.string,cssModule:t.object},h=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(h,e.Component);var r,c,b,d=p(h);function h(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(t=d.call(this,e)).getRef=t.getRef.bind(y(t)),t.focus=t.focus.bind(y(t)),t}return r=h,(c=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var t=this.props,r=t.className,c=t.cssModule,u=t.type,l=void 0===u?"text":u,p=t.bsSize,y=t.valid,b=t.invalid,d=t.tag,h=t.addon,v=t.plaintext,m=t.innerRef,O=s(t,f),g=["switch","radio","checkbox"].indexOf(l)>-1,j="select"===l,w="range"===l,x=d||(j||"textarea"===l?l:"input"),P="form-control";v?(P="".concat(P,"-plaintext"),x=d||"input"):w?P="form-range":j?P="form-select":g&&(P=h?null:"form-check-input"),O.size&&/\D/g.test(O.size)&&(o('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),p=O.size,delete O.size);var R=i(n(r,b&&"is-invalid",y&&"is-valid",!!p&&(j?"form-select-".concat(p):"form-control-".concat(p)),P),c);return("input"===x||d&&"function"==typeof d)&&(O.type="switch"===l?"checkbox":l),O.children&&!v&&"select"!==l&&"string"==typeof x&&"select"!==x&&(o('Input with a type of "'.concat(l,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete O.children),e.createElement(x,a({},O,{ref:m,className:R,"aria-invalid":b}))}}])&&u(r.prototype,c),b&&u(r,b),Object.defineProperty(r,"prototype",{writable:!1}),h}();h.propTypes=d;var v=h;export{v as default};
//# sourceMappingURL=Input.js.map
