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

var _chunkJZ3TGO3Dcjs = require('./chunk-JZ3TGO3D.cjs');


var _chunkMFKERIW4cjs = require('./chunk-MFKERIW4.cjs');


var _chunkWF7Z2VITcjs = require('./chunk-WF7Z2VIT.cjs');


var _chunkEDMCWD63cjs = require('./chunk-EDMCWD63.cjs');


var _chunkJA7KZV3Qcjs = require('./chunk-JA7KZV3Q.cjs');


var _chunkN6HLM4KCcjs = require('./chunk-N6HLM4KC.cjs');



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

// src/components/ClipboardTextField.tsx
var _react = require('@emotion/react');
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _react3 = require('react');
var _jsxruntime = require('@emotion/react/jsx-runtime');
function ClipboardTextField({
  value,
  icon,
  iconName,
  id,
  stopPropagation,
  maxLines,
  elide: elideArgs,
  wordBreakAll = false,
  tag = "span",
  iconSide = "left",
  iconColor: iconColorProp,
  typography,
  clipboardCallbacks
}) {
  const theme = _react.useTheme.call(void 0, );
  const { canWriteToClipboard, writeTextToClipboard } = _chunkJZ3TGO3Dcjs.useClipboard.call(void 0, clipboardCallbacks);
  const addLineClamp = Boolean(maxLines && maxLines > 1);
  const displayValue = elideArgs ? _chunkJA7KZV3Qcjs.elide.call(void 0, value, elideArgs) : value;
  const valueNode = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    ClipboardTextFieldValue,
    {
      wordBreakAll,
      typography,
      addLineClamp,
      maxLines,
      children: displayValue
    }
  );
  const onClick = _react3.useCallback.call(void 0, 
    (event) => {
      if (stopPropagation) {
        event.stopPropagation();
      }
      void writeTextToClipboard(value);
    },
    [stopPropagation, value, writeTextToClipboard]
  );
  function onKeyDown(event) {
    if (event.key === "Enter" || event.key === " ") {
      if (stopPropagation) {
        event.stopPropagation();
      }
      void writeTextToClipboard(value);
    }
  }
  const commonProps = {
    as: tag,
    id,
    addLineClamp,
    maxLines
  };
  const typographyType = (typography == null ? void 0 : typography.type) || "Body";
  const typographySize = (typography == null ? void 0 : typography.size) || "ExtraSmall";
  const lineHeight = _chunkN6HLM4KCcjs.getLineHeightNumberForTypographyType.call(void 0, 
    typographyType,
    typographySize,
    theme
  );
  const iconColor = iconColorProp || (typography == null ? void 0 : typography.color) || "inherit";
  return canWriteToClipboard && value ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, 
    StyledClipboardTextField,
    _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {
      onClick,
      role: "button",
      tabIndex: 0,
      onKeyDown
    }, commonProps), {
      children: [
        icon && iconSide === "left" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
          _chunkWF7Z2VITcjs.Icon,
          {
            name: iconName || "Copy",
            width: lineHeight * 0.7,
            mr: lineHeight * 0.3,
            color: iconColor
          }
        ) : null,
        valueNode,
        icon && iconSide === "right" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
          _chunkWF7Z2VITcjs.Icon,
          {
            name: iconName || "Copy",
            width: lineHeight * 0.7,
            ml: lineHeight * 0.3,
            color: iconColor
          }
        ) : null
      ]
    })
  ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StyledClipboardTextField, _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, commonProps), { children: valueNode }));
}
var StyledClipboardTextField = _styled2.default.span`
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  align-items: center;
  box-sizing: content-box;
  cursor: pointer;

  ${({ addLineClamp, maxLines }) => (
  /* keep the icon on the same line when addLineClamp: */
  addLineClamp || maxLines === 1 ? "display: inline-flex;" : ""
)}

  ${({ maxLines }) => maxLines === 1 ? "white-space: nowrap;" : ""}
`;
var ClipboardTextFieldValue = _styled2.default.span`
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  word-break: ${({ wordBreakAll }) => wordBreakAll ? "break-all" : "normal"};
  vertical-align: middle;

  ${({ addLineClamp, maxLines }) => addLineClamp && maxLines ? `
        ${_chunkMFKERIW4cjs.lineClamp.call(void 0, maxLines).styles}
        align-self: baseline;
      ` : ""}

  ${({ theme, typography }) => _chunkEDMCWD63cjs.applyTypography.call(void 0, 
  theme,
  (typography == null ? void 0 : typography.type) || "Body",
  (typography == null ? void 0 : typography.size) || "ExtraSmall",
  (typography == null ? void 0 : typography.color) || "inherit"
)}
`;



exports.ClipboardTextField = ClipboardTextField;
