"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var SplitInput_exports = {};
__export(SplitInput_exports, {
  default: () => SplitInput
});
module.exports = __toCommonJS(SplitInput_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_BaseInput = require("../BaseInput");
function getDividerColor(props) {
  var _a, _b, _c, _d;
  if (props.disabled) {
    return (_a = props.theme) == null ? void 0 : _a.colors.neutral.c40;
  }
  if (props.error) {
    return (_b = props.theme) == null ? void 0 : _b.colors.error.c50;
  }
  if (props.focus) {
    return (_c = props.theme) == null ? void 0 : _c.colors.primary.c80;
  }
  return (_d = props.theme) == null ? void 0 : _d.colors.neutral.c40;
}
function getHoverBolderColor(props) {
  var _a;
  return props.disabled || props.error ? "inherit" : (_a = props.theme) == null ? void 0 : _a.colors.primary.c80;
}
const Divider = import_styled_components.default.div`
  border-right: 1px solid;
  height: 100%;
  transition: border-color 0.2s ease;

  border-color: ${getDividerColor};
  ${import_BaseInput.InputContainer}:hover & {
    border-color: ${getHoverBolderColor};
  }
`;
function SplitInput(props) {
  const { disabled, isDisabled, renderLeft, renderRight, error } = props;
  const [focus, setFocus] = import_react.default.useState(false);
  const onFocus = (0, import_react.useCallback)(() => {
    setFocus(true);
  }, [setFocus]);
  const onBlur = (0, import_react.useCallback)(() => {
    setFocus(false);
  }, [setFocus]);
  const disabledState = typeof disabled !== "undefined" ? disabled : isDisabled;
  return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_BaseInput.InputContainer, { disabled: disabledState, focus, error }, /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "50%", height: "100%" } }, renderLeft({
    error,
    onFocus,
    onBlur,
    disabled: disabledState,
    isDisabled: disabledState
  })), /* @__PURE__ */ import_react.default.createElement(Divider, { focus, disabled, error }), /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "50%", height: "100%" } }, typeof renderRight === "function" ? renderRight({
    error,
    onFocus,
    onBlur,
    disabled: disabledState,
    isDisabled: disabledState
  }) : renderRight)), error && !disabled && /* @__PURE__ */ import_react.default.createElement(import_BaseInput.InputErrorContainer, null, error));
}
//# sourceMappingURL=index.js.map
