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

import { h as helper } from '../_chunks/dep-c89aafbb.js';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs } from '@vue/composition-api';
import useVModel from '../hooks/useVModel.js';
import { renderTNodeJSXDefault } from '../utils/render-tnode.js';
import { Popup } from '../popup/index.js';
import props from './props.js';
import ColorPanel from './panel/index.js';
import DefaultTrigger from './trigger.js';
import { useBaseClassName } from './hooks.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/kebabCase';
import 'vue';
import 'lodash/camelCase';
import '../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import '../popup/popup.js';
import '@popperjs/core';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/helper.js';
import '../_common/js/utils/set-style.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/event.js';
import '../popup/props.js';
import '../popup/container.js';
import 'lodash/isFunction';
import '../popup/utils.js';
import '../popup/trigger.js';
import '../popup/style';
import '../popup/type.js';
import '../popup/plugin.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import '../hooks/useCommonClassName.js';
import './const.js';
import '../_common/js/color-picker/constants.js';
import './utils/index.js';
import '../_common/js/color-picker/index.js';
import '../_common/js/color-picker/cmyk.js';
import '../_common/js/color-picker/color.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import 'tinycolor2';
import '../_common/js/color-picker/gradient.js';
import 'lodash/isNull';
import '../_common/js/color-picker/draggable.js';
import '../hooks/useDefaultValue.js';
import './panel/header.js';
import '../radio/index.js';
import '../radio/radio.js';
import '../radio/props.js';
import '../radio/group.js';
import 'lodash/isNumber';
import '../radio/radio-group-props.js';
import '../radio/radio-button.js';
import '../radio/style';
import '../radio/type.js';
import './panel/linear-gradient.js';
import 'lodash/cloneDeep';
import '../input-number/index.js';
import '../input-number/input-number.js';
import '@ldesign/icons-vue';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import 'lodash/isObject';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../loading/plugin.js';
import '../config.js';
import '../loading/loading.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import 'lodash/isUndefined';
import 'lodash/isArray';
import '../loading/style';
import '../loading/type.js';
import '../utils/ripple.js';
import '../button/props.js';
import '../button/style';
import '../button/type.js';
import '../input/index.js';
import '../input/input.js';
import '../_common/js/log/index.js';
import '../_common/js/log/log.js';
import '../input/props.js';
import '../input/input-group.js';
import '../input/style';
import '../input/type.js';
import '../hooks/useGlobalIcon.js';
import '../input-number/props.js';
import '../input-number/useInputNumber.js';
import '../_common/js/input-number/number.js';
import 'lodash/isNil';
import '../_common/js/input-number/large-number.js';
import '../hooks/useFormDisabled.js';
import '../input-number/style';
import '../input-number/type.js';
import './panel/base-props.js';
import './panel/saturation.js';
import '../select/index.js';
import '../select/select.js';
import 'lodash/debounce';
import 'lodash/get';
import '../hooks/tnode.js';
import 'lodash/isEmpty';
import '../hooks/render-tnode.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../tag/style';
import '../tag/type.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import 'lodash/pick';
import '../select-input/useMultiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../tag-input/style';
import '../tag-input/type.js';
import '../tag-input/interface.js';
import '../select-input/useOverlayInnerStyle.js';
import '../select-input/style';
import '../select-input/type.js';
import '../common-components/fake-arrow.js';
import '../select/option.js';
import '../checkbox/index.js';
import '../checkbox/group.js';
import 'lodash/intersection';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../checkbox/checkbox-group-props.js';
import '../checkbox/style';
import '../checkbox/type.js';
import '../hooks/useLazyLoad.js';
import '../_common/js/utils/observe.js';
import '../select/util.js';
import '../select/option-props.js';
import '../select/select-panel.js';
import '../hooks/useVirtualScroll.js';
import '../select/hooks/useSelectOptions.js';
import '../select/props.js';
import '../select/optionGroup.js';
import '../select/option-group-props.js';
import '../select/style';
import '../select/type.js';
import './panel/hue.js';
import './panel/slider.js';
import './panel/alpha.js';
import './panel/format/index.js';
import 'lodash/upperCase';
import './panel/format/inputs.js';
import 'lodash/throttle';
import './panel/format/config.js';
import './panel/swatches.js';
import 'lodash';

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(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 = defineComponent({
  name: "TColorPicker",
  components: {
    TPopup: Popup,
    ColorPanel: ColorPanel,
    DefaultTrigger: DefaultTrigger
  },
  props: _objectSpread({}, props),
  setup: function setup(props2) {
    var baseClassName = useBaseClassName();
    var visible = ref(false);
    var setVisible = function setVisible(value2) {
      return visible.value = value2;
    };
    var _toRefs = toRefs(props2),
      value = _toRefs.value;
    var _useVModel = useVModel(value, props2.defaultValue, props2.onChange, "change"),
      _useVModel2 = _slicedToArray(_useVModel, 2),
      innerValue = _useVModel2[0],
      setInnerValue = _useVModel2[1];
    var handleChange = function handleChange(value2, context) {
      setInnerValue(value2, context);
    };
    var handlePaletteChange = function handlePaletteChange(context) {
      props2.onPaletteBarChange(context);
    };
    return {
      baseClassName: baseClassName,
      innerValue: innerValue,
      visible: visible,
      setVisible: setVisible,
      setInnerValue: setInnerValue,
      handleChange: handleChange,
      handlePaletteChange: handlePaletteChange
    };
  },
  render: function render() {
    var _this = this;
    var h = arguments[0];
    var popupProps = this.popupProps,
      disabled = this.disabled,
      innerValue = this.innerValue,
      baseClassName = this.baseClassName,
      setVisible = this.setVisible,
      handleChange = this.handleChange,
      handlePaletteChange = this.handlePaletteChange;
    var renderPopupContent = function renderPopupContent() {
      if (disabled) return null;
      return h("color-panel", helper([{
        "props": _objectSpread({}, _objectSpread(_objectSpread({}, _this.$props), {}, {
          value: innerValue
        })),
        "attrs": {
          "togglePopup": setVisible
        }
      }, {
        "on": {
          change: handleChange,
          handlePaletteChange: handlePaletteChange
        }
      }, {
        "ref": "refColorPanel"
      }]));
    };
    var popProps = _objectSpread({
      placement: "bottom-left",
      trigger: "click",
      attach: "body",
      overlayClassName: [baseClassName],
      visible: this.visible,
      overlayInnerStyle: {
        padding: 0
      },
      onVisibleChange: function onVisibleChange(visible, context) {
        if (context.trigger === "document") _this.setVisible(false);
      }
    }, popupProps || {});
    return h("l-popup", {
      "props": _objectSpread({}, _objectSpread({}, popProps)),
      "attrs": {
        "content": renderPopupContent
      }
    }, [h("div", {
      "class": "".concat(baseClassName, "__trigger"),
      "on": {
        "click": function click() {
          return setVisible(!_this.visible);
        }
      }
    }, [renderTNodeJSXDefault(this, "default", h("default-trigger", {
      "attrs": {
        "color": this.innerValue,
        "disabled": disabled,
        "clearable": this.clearable,
        "input-props": this.inputProps,
        "handleTriggerChange": this.setInnerValue
      }
    }))])]);
  }
});

export { _ColorPicker as default };
//# sourceMappingURL=color-picker.js.map
