"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    MoveDirection: function() {
        return MoveDirection;
    },
    SearchForm: function() {
        return SearchForm;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _input = require("../../../input");
const _inputMask = require("../../../input/inputMask");
const _hooks = require("@orderly.network/hooks");
const _lucidereact = require("lucide-react");
var MoveDirection;
(function(MoveDirection) {
    MoveDirection[MoveDirection["Up"] = 0] = "Up";
    MoveDirection[MoveDirection["Down"] = 1] = "Down";
})(MoveDirection || (MoveDirection = {}));
const SearchForm = (props)=>{
    const onMoving = (direction, e)=>{
        props.onMoving?.(direction);
        e.preventDefault();
    };
    const handleKeyDown = (e)=>{
        const { keyCode } = e;
        if (keyCode === 40) {
            // console.log("down")
            onMoving?.(1, e);
        } else if (keyCode === 38) {
            // console.log("up")
            onMoving?.(0, e);
        } else if (keyCode === 13) {
            // console.log("enter")
            // onMoving?.(MoveDirection.Up, e);
            props.onSymbolSelect?.();
        }
    };
    const onChange = (0, _hooks.useDebouncedCallback)((e)=>{
        // console.log(e.target.value);
        props.onSearch(e.target.value);
    }, 200);
    // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    // }
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_input.Input, {
        placeholder: "Search",
        onKeyDown: handleKeyDown,
        onChange: onChange,
        autoFocus: true,
        // value={props.keyword}
        prefix: /*#__PURE__*/ (0, _jsxruntime.jsx)(_inputMask.InputMask, {
            children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.Search, {
                size: 20,
                className: "orderly-text-base-contrast-20"
            })
        })
    });
};

//# sourceMappingURL=search.js.map