/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { defineComponent, createVNode } from 'vue';
import { FileCopyIcon } from '@ldesign/icons-vue-next';
import { copyText } from '../utils/clipboard.js';
import MessagePlugin from '../message/plugin.js';
import { Popup } from '../popup/index.js';
import { useGlobalIcon } from '../hooks/useGlobalIcon.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import props from './anchor-target-props.js';
import { useConfig } from '../config-provider/useConfig.js';
import '../_chunks/dep-2e5d8948.js';
import '@babel/runtime/helpers/defineProperty';
import 'lodash/isObject';
import 'lodash/isString';
import '../utils/dom.js';
import 'lodash/isFunction';
import 'lodash/isArray';
import '../utils/easing.js';
import '../message/messageList.js';
import '../message/const.js';
import '../message/message.js';
import '../loading/index.js';
import '../utils/withInstall.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../loading/loading.js';
import '@babel/runtime/helpers/slicedToArray';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import 'dayjs';
import '../_chunks/dep-4580aabe.js';
import '../config-provider/type.js';
import '../loading/style';
import '../loading/type.js';
import '../hooks/tnode.js';
import '../message/props.js';
import '../message/animation.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../hooks/index.js';
import '../hooks/icon.js';
import '../hooks/slot.js';
import '../hooks/useCommonClassName.js';
import '../hooks/useDefaultValue.js';
import '../hooks/useDestroyOnClose.js';
import '../hooks/useKeepAnimation.js';
import '../hooks/useRipple.js';
import '../utils/set-style.js';
import '../hooks/useVirtualScroll.js';
import '../hooks/useVModel.js';
import '../popup/container.js';
import '../hooks/useResizeObserver.js';
import '../popup/props.js';
import '../popup/style';
import '../popup/type.js';

var _AnchorTarget = defineComponent({
  name: "TAnchorTarget",
  props: props,
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var _useConfig = useConfig("anchor"),
      globalConfig = _useConfig.globalConfig,
      classPrefix = _useConfig.classPrefix;
    var _useGlobalIcon = useGlobalIcon({
        FileCopyIcon: FileCopyIcon
      }),
      FileCopyIcon$1 = _useGlobalIcon.FileCopyIcon;
    var COMPONENT_NAME = usePrefixClass("anchor");
    var toCopyText = function toCopyText() {
      var a = document.createElement("a");
      a.href = "#".concat(props2.id);
      copyText(a.href);
      MessagePlugin.success(globalConfig.value.copySuccessText, 1e3);
    };
    return function () {
      var children = slots["default"];
      var TAG = props2.tag,
        id = props2.id;
      var className = ["".concat(COMPONENT_NAME.value, "__target")];
      var iconClassName = "".concat(classPrefix.value, "-copy");
      return createVNode(TAG, {
        "id": id,
        "class": className
      }, {
        "default": function _default() {
          return [children && children(null), createVNode(Popup, {
            "content": globalConfig.value.copyText,
            "placement": "top",
            "showArrow": true,
            "class": iconClassName
          }, {
            "default": function _default() {
              return [createVNode(FileCopyIcon$1, {
                "onClick": toCopyText
              }, null)];
            }
          })];
        }
      });
    };
  }
});

export { _AnchorTarget as default };
//# sourceMappingURL=anchor-target.js.map
