import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from '../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { copyToClipboard } from '../utils/copy-to-clipboard.js';
import EuiToolTip from './eui-tool-tip.js';

var _class, _descriptor;
let EuiCopyComponent = setComponentTemplate(precompileTemplate(`
    <EuiToolTip
      @content={{this.tooltipText}}
      @onMouseOut={{this.resetTooltipText}}
      ...attributes
    >
      <:anchor>
        {{yield this.copy}}
      </:anchor>
    </EuiToolTip>
  `, {
  strictMode: true,
  scope: () => ({
    EuiToolTip
  })
}), (_class = class EuiCopyComponent extends Component {
  constructor(...args) {
    super(...args);
    _initializerDefineProperty(this, "tooltipText", _descriptor, this);
  }
  copy() {
    const isCopied = copyToClipboard(this.args.textToCopy);
    if (isCopied) {
      this.tooltipText = this.args.afterMessage;
    }
  }
  resetTooltipText() {
    this.tooltipText = this.args.beforeMessage;
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "tooltipText", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return this.args.beforeMessage;
  }
}), _applyDecoratedDescriptor(_class.prototype, "copy", [action], Object.getOwnPropertyDescriptor(_class.prototype, "copy"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "resetTooltipText", [action], Object.getOwnPropertyDescriptor(_class.prototype, "resetTooltipText"), _class.prototype)), _class));

export { EuiCopyComponent as default };
//# sourceMappingURL=eui-copy.js.map
