"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkY45PAGZ2cjs = require('./chunk-Y45PAGZ2.cjs');


var _chunkJTXWWEZAcjs = require('./chunk-JTXWWEZA.cjs');


var _chunkTXDLUYVGcjs = require('./chunk-TXDLUYVG.cjs');



var _chunkZ6EUSUADcjs = require('./chunk-Z6EUSUAD.cjs');

// src/components/DataManagerTable/CurrencyFilter.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _core = require('@lightsparkdev/core');
var _react = require('react');
var _jsxruntime = require('@emotion/react/jsx-runtime');
var isCurrencyFilterState = (state) => state.type === "currency" /* CURRENCY */;
var getDefaultCurrencyFilterState = () => ({
  type: "currency" /* CURRENCY */,
  min_amount: null,
  max_amount: null,
  isApplied: false
});
var CurrencyFilter = ({
  updateFilterState,
  state,
  label
}) => {
  var _a, _b, _c, _d;
  const [filterRangeType, setFilterRangeType] = _react.useState.call(void 0, 
    "Less than" /* LessThan */
  );
  const isMinDisplayed = filterRangeType !== "Less than" /* LessThan */;
  const isMaxDisplayed = filterRangeType !== "More than" /* MoreThan */;
  const handleMinChange = (value) => {
    updateFilterState(_chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, state), {
      min_amount: value ? { value: parseInt(value), unit: _core.CurrencyUnit.SATOSHI } : null,
      isApplied: state.max_amount !== null || !!value
    }));
  };
  const handleMaxChange = (value) => {
    updateFilterState(_chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, state), {
      max_amount: value ? { value: parseInt(value), unit: _core.CurrencyUnit.SATOSHI } : null,
      isApplied: state.min_amount !== null || !!value
    }));
  };
  const handleClick = (type) => {
    setFilterRangeType(type);
    updateFilterState(_chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, state), {
      min_amount: null,
      max_amount: null,
      isApplied: false
    }));
  };
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkY45PAGZ2cjs.Filter, { label, children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      NumberButtonRowContainer,
      {
        smSticky: false,
        bottomBorder: false,
        buttons: [
          {
            text: "Less than",
            kind: filterRangeType === "Less than" /* LessThan */ ? "primary" : void 0,
            onClick: () => handleClick("Less than" /* LessThan */),
            size: "ExtraSmall"
          },
          {
            text: "Between",
            kind: filterRangeType === "Between" /* Between */ ? "primary" : void 0,
            onClick: () => handleClick("Between" /* Between */),
            size: "ExtraSmall"
          },
          {
            text: "More than",
            kind: filterRangeType === "More than" /* MoreThan */ ? "primary" : void 0,
            onClick: () => handleClick("More than" /* MoreThan */),
            size: "ExtraSmall"
          }
        ]
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, InputContainer, { children: [
      isMinDisplayed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
        _chunkJTXWWEZAcjs.NumberInput_default,
        {
          placeholder: "0",
          onChange: handleMinChange,
          value: ((_b = (_a = state.min_amount) == null ? void 0 : _a.value) == null ? void 0 : _b.toString()) || "",
          icon: { name: "Satoshi", side: "left", width: 8 },
          typography: { color: "black" },
          allowNegativeValue: true
        }
      ),
      isMinDisplayed && isMaxDisplayed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Divider, {}),
      isMaxDisplayed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
        _chunkJTXWWEZAcjs.NumberInput_default,
        {
          placeholder: "0",
          onChange: handleMaxChange,
          value: ((_d = (_c = state.max_amount) == null ? void 0 : _c.value) == null ? void 0 : _d.toString()) || "",
          icon: { name: "Satoshi", side: "left", width: 8 },
          typography: { color: "black" },
          allowNegativeValue: true
        }
      )
    ] })
  ] }) });
};
var NumberButtonRowContainer = _styled2.default.call(void 0, _chunkTXDLUYVGcjs.ButtonRow)`
  padding: 0px !important;
`;
var InputContainer = _styled2.default.div`
  display: flex;
  flex-direction: row;
  margin-top: 24px;
  gap: 10px;
  align-items: center;
`;
var Divider = _styled2.default.div`
  height: 4px;
  width: 12px;
  flex-shrink: 0;
  border-radius: 999px;
  background-color: ${({ theme }) => theme.c1Neutral};
`;





exports.isCurrencyFilterState = isCurrencyFilterState; exports.getDefaultCurrencyFilterState = getDefaultCurrencyFilterState; exports.CurrencyFilter = CurrencyFilter;
