"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Icon_1 = require("../Icon");
const Mousetrap = __importStar(require("mousetrap"));
const React = __importStar(require("react"));
const react_debounce_input_1 = require("react-debounce-input");
const react_jss_1 = __importDefault(require("react-jss"));
const types_1 = require("../../types");
const styles = (theme) => types_1.createStyles({
    container: {
        padding: [0, 10],
        height: 40,
        borderRadius: 20,
        width: '100%',
        maxWidth: 600,
        display: 'flex',
        alignItems: 'center',
        color: '#999',
        overflow: 'hidden',
        backgroundColor: theme.colors.gray.light,
    },
    icon: {
        fill: '#949494',
        width: 25,
        height: 25,
    },
    input: {
        border: 'none',
        flexGrow: 1,
        height: '100%',
        fontSize: '14px',
        backgroundColor: 'transparent',
    },
});
class SearchInputImpl extends React.PureComponent {
    constructor(props) {
        super(props);
        this.handleInputChange = (e) => {
            this.props.onChange(e.target.value);
        };
        this.inputRef = React.createRef();
    }
    componentWillMount() {
        Mousetrap.bind('mod+f', (e) => {
            if (this.inputRef) {
                e.preventDefault();
                this.inputRef.current.focus();
            }
        }, 'keydown');
    }
    componentWillUnmount() {
        Mousetrap.unbind('mod+f');
    }
    render() {
        const { classes, placeholder, value, autofocus } = this.props;
        return (React.createElement("div", { className: classes.container },
            React.createElement(Icon_1.Icon, { symbolId: Icon_1.IconSymbol.SEARCH, size: 40, className: classes.icon }),
            React.createElement(react_debounce_input_1.DebounceInput, { minLength: 0, debounceTimeout: 150, className: classes.input, autoFocus: autofocus, type: "search", placeholder: placeholder, value: value, onChange: this.handleInputChange, ref: this.inputRef })));
    }
}
exports.SearchInput = react_jss_1.default(styles)(SearchInputImpl);
//# sourceMappingURL=index.js.map