"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/atoms/auto-sizing-input.tsx
var auto_sizing_input_exports = {};
__export(auto_sizing_input_exports, {
  AutoSizingInput: () => AutoSizingInput
});
module.exports = __toCommonJS(auto_sizing_input_exports);
var import_react = require("react");
var import_jsx_runtime = require("react/jsx-runtime");
var AutoSizingInput = (0, import_react.forwardRef)(
  (_a, ref) => {
    var _b = _a, { value: _value, onChangeValue, onChange } = _b, rest = __objRest(_b, ["value", "onChangeValue", "onChange"]);
    const [value, setValue] = (0, import_react.useState)(_value);
    const [width, setWidth] = (0, import_react.useState)(0);
    const span = (0, import_react.useRef)(null);
    const defaultRef = (0, import_react.useRef)(null);
    const inputRef = ref || defaultRef;
    (0, import_react.useEffect)(() => {
      span.current && setWidth(span.current.offsetWidth);
    }, [value]);
    const changeHandler = (0, import_react.useCallback)(
      (evt) => {
        onChange == null ? void 0 : onChange(evt);
        setValue(evt.target.value);
      },
      [onChange]
    );
    (0, import_react.useEffect)(() => {
      setValue(_value || "");
    }, [_value]);
    (0, import_react.useEffect)(() => {
      onChangeValue == null ? void 0 : onChangeValue(value || "");
    }, [value, onChangeValue]);
    const onClick = (0, import_react.useCallback)(() => {
      var _a2;
      if ("current" in inputRef) {
        (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
      }
    }, [inputRef]);
    const onKeyDown = (0, import_react.useCallback)(
      (evt) => {
        if (evt.key === "Enter") {
          onClick();
        }
      },
      [onClick]
    );
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
      "div",
      {
        className: "auto-sizing-input wrapper",
        onClick,
        onKeyDown,
        role: "button",
        style: { width: `${width + 24}px` },
        tabIndex: 0,
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", ref: span, style: rest.style, children: value || rest.placeholder || "" }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
            "input",
            __spreadValues({
              onChange: changeHandler,
              ref: inputRef,
              value
            }, rest)
          )
        ]
      }
    );
  }
);
AutoSizingInput.displayName = "AutoSizingInput";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AutoSizingInput
});
//# sourceMappingURL=auto-sizing-input.cjs.map