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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var hooks_useVModel = require('../hooks/useVModel.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var popup_index = require('../popup/index.js');
var colorPicker_props = require('./props.js');
var colorPicker_panel_index = require('./panel/index.js');
var colorPicker_trigger = require('./trigger.js');
var colorPicker_hooks = require('./hooks.js');
require('lodash/kebabCase');
require('lodash/isEmpty');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isObject');
require('lodash/camelCase');
require('../utils/withInstall.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-f4db2590.js');
require('dayjs');
require('../utils/dom.js');
require('../utils/easing.js');
require('../_common/js/utils/set-style.js');
require('../popup/props.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isUndefined');
require('../hooks/useResizeObserver.js');
require('../hooks/useDefaultValue.js');
require('./panel/header.js');
require('../radio/index.js');
require('../radio/radio.js');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isNumber');
require('../form/hooks.js');
require('../hooks/tnode.js');
require('../radio/constants.js');
require('../radio/props.js');
require('../radio/group.js');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('lodash/isNil');
require('../radio/radio-group-props.js');
require('../radio/useKeyboard.js');
require('../radio/radio-button.js');
require('../_common/js/color-picker/constants.js');
require('./panel/linear-gradient.js');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('@ldesign/icons-vue-next');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/helper.js');
require('../hooks/useRipple.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../button/props.js');
require('../input/index.js');
require('../input/input.js');
require('../hooks/useGlobalIcon.js');
require('../input/props.js');
require('../input/useInput.js');
require('../form/const.js');
require('../input/useLengthLimit.js');
require('../_common/js/log/log.js');
require('../input/useInputEventHandler.js');
require('../input/useInputWidth.js');
require('../input/input-group.js');
require('../input/input-group-props.js');
require('../input-number/props.js');
require('../input-number/useInputNumber.js');
require('../hooks/useCommonClassName.js');
require('../_common/js/input-number/number.js');
require('../_common/js/input-number/large-number.js');
require('./panel/base-props.js');
require('../_common/js/color-picker/color.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('tinycolor2');
require('../_common/js/color-picker/cmyk.js');
require('../_common/js/color-picker/gradient.js');
require('./panel/saturation.js');
require('../_common/js/color-picker/draggable.js');
require('./panel/hue.js');
require('./panel/slider.js');
require('./panel/alpha.js');
require('./panel/format/index.js');
require('lodash/upperCase');
require('./const.js');
require('../select/index.js');
require('../select/select.js');
require('lodash/pick');
require('lodash/debounce');
require('lodash/get');
require('lodash/intersection');
require('../common-components/fake-arrow.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../select-input/useOverlayInnerStyle.js');
require('../select/props.js');
require('../select/select-panel.js');
require('lodash/omit');
require('../select/option.js');
require('../checkbox/index.js');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../checkbox/constants.js');
require('../checkbox/group.js');
require('../hooks/slot.js');
require('../checkbox/checkbox-group-props.js');
require('../select/option-props.js');
require('../select/helper.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../select/hooks/usePanelVirtualScroll.js');
require('../hooks/useVirtualScroll.js');
require('../select/hooks/useSelectOptions.js');
require('./panel/format/inputs.js');
require('lodash/throttle');
require('./panel/format/config.js');
require('./panel/swatches.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _ColorPicker = vue.defineComponent({
  name: "TColorPicker",
  props: _objectSpread({}, colorPicker_props["default"]),
  setup: function setup(props2) {
    var baseClassName = colorPicker_hooks.useBaseClassName();
    var visible = vue.ref(false);
    var setVisible = function setVisible(value) {
      return visible.value = value;
    };
    var _toRefs = vue.toRefs(props2),
      inputValue = _toRefs.value,
      modelValue = _toRefs.modelValue;
    var _useVModel = hooks_useVModel["default"](inputValue, modelValue, props2.defaultValue, props2.onChange),
      _useVModel2 = _slicedToArray__default["default"](_useVModel, 2),
      innerValue = _useVModel2[0],
      setInnerValue = _useVModel2[1];
    var refTrigger = vue.ref();
    var renderPopupContent = function renderPopupContent() {
      if (props2.disabled) return null;
      var newProps = _objectSpread({}, props2);
      delete newProps.onChange;
      return vue.createVNode(colorPicker_panel_index["default"], vue.mergeProps(newProps, {
        "disabled": props2.disabled,
        "value": innerValue.value,
        "togglePopup": setVisible,
        "onChange": function onChange(value, context) {
          return setInnerValue(value, context);
        }
      }), null);
    };
    return {
      baseClassName: baseClassName,
      innerValue: innerValue,
      visible: visible,
      refTrigger: refTrigger,
      renderPopupContent: renderPopupContent,
      setVisible: setVisible,
      setInnerValue: setInnerValue
    };
  },
  render: function render() {
    var _this = this;
    var popupProps = this.popupProps,
      baseClassName = this.baseClassName;
    var popProps = _objectSpread(_objectSpread({
      placement: "bottom-left"
    }, popupProps || {}), {}, {
      trigger: "click",
      attach: "body",
      overlayClassName: [baseClassName],
      visible: this.visible,
      overlayInnerStyle: {
        padding: 0
      },
      onVisibleChange: function onVisibleChange(visible, context) {
        if (context.trigger === "document") _this.setVisible(false);
      }
    });
    return vue.createVNode(popup_index.Popup, vue.mergeProps(popProps, {
      "content": this.renderPopupContent
    }), {
      "default": function _default() {
        return [vue.createVNode("div", {
          "class": "".concat(baseClassName, "__trigger"),
          "onClick": function onClick() {
            return _this.setVisible(!_this.visible);
          },
          "ref": "refTrigger"
        }, [utils_renderTnode.renderTNodeJSXDefault(_this, "default", vue.createVNode(colorPicker_trigger["default"], {
          "color": _this.innerValue,
          "disabled": _this.disabled,
          "clearable": _this.clearable,
          "input-props": _this.inputProps,
          "onTriggerChange": _this.setInnerValue
        }, null))])];
      }
    });
  }
});

exports["default"] = _ColorPicker;
//# sourceMappingURL=color-picker.js.map
