/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

import { h as helper } from '../../_chunks/dep-b0f1ed22.js';
import { defineComponent, ref, toRefs } from '@vue/composition-api';
import useVModel from '../../hooks/useVModel.js';
import { renderLNodeJSXDefault } from '../../utils/render-node.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/index.js';
import 'lodash/kebabCase';
import 'vue';
import 'lodash';
import '../../utils/map-props.js';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import '../../config.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../_chunks/dep-c68dc4b6.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../_chunks/dep-eaa95999.js';
import '../../_chunks/dep-102361be.js';
import '../../utils/easing.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../../_chunks/dep-b4fd1955.js';
import '../../utils/mixins.js';
import '../popup/props.js';
import '../popup/container.js';
import '../config-provider/useConfig.js';
import '../../hooks/useCommonClassName.js';
import '../../_chunks/dep-560aa956.js';
import '../../_chunks/dep-836dea4a.js';
import '../../_chunks/dep-aacc31a3.js';
import '../../hooks/useDefaultValue.js';
import './panel/header.js';
import '../radio/index.js';
import '../radio/radio.js';
import '../../utils/event.js';
import '../radio/props.js';
import '../radio/group.js';
import 'lodash/isNumber';
import '../radio/radio-button.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/loading.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-1a6bca30.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';
import '../input/index.js';
import '../input/input.js';
import '../input/props.js';
import '../input/group.js';
import '../../hooks/useGlobalIcon.js';
import '../input-number/props.js';
import '../input-number/hooks/use-input-number.js';
import '../../_chunks/dep-52c80d08.js';
import '../../_chunks/dep-25603871.js';
import '../../_chunks/dep-7b293b33.js';
import '../../hooks/useFormDisabled.js';
import './panel/base-props.js';
import './panel/saturation.js';
import '../select/index.js';
import '../select/select.js';
import 'lodash/isFunction';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/isArray';
import 'lodash/isObject';
import '../../hooks/lnode.js';
import 'lodash/isEmpty';
import '../../hooks/render-lnode.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/hooks/use-single.js';
import 'lodash/pick';
import '../../hooks/useConfig.js';
import '../select-input/hooks/use-multiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/use-tag-scroll.js';
import '../tag-input/hooks/use-tag-list.js';
import '../tag-input/hooks/use-hover.js';
import '../tag-input/hooks/use-drag-sorter.js';
import '../select-input/hooks/use-overlay-innerstyle.js';
import '../common/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 '../../hooks/useLazyLoad.js';
import '../../_chunks/dep-62ed000f.js';
import '../select/utils.js';
import '../select/props.js';
import '../select/select-panel.js';
import '../../hooks/useVirtualScroll.js';
import '../select/hooks/use-select-options.js';
import '../select/option-group.js';
import '../../_chunks/dep-c1fcce9c.js';
import './panel/hue.js';
import './panel/slider.js';
import './panel/alpha.js';
import './panel/format/index.js';
import 'lodash/upperCase';
import './const.js';
import './panel/format/inputs.js';
import 'lodash/throttle';
import './panel/format/config.js';
import './panel/swatches.js';

var _ColorPicker = defineComponent({
  name: "LColorPicker",
  components: {
    TPopup: Popup,
    ColorPanel,
    DefaultTrigger
  },
  props: {
    ...props
  },
  setup(props2) {
    const baseClassName = useBaseClassName();
    const visible = ref(false);
    const setVisible = value2 => visible.value = value2;
    const {
      value
    } = toRefs(props2);
    const [innerValue, setInnerValue] = useVModel(value, props2.defaultValue, props2.onChange, "change");
    const handleChange = (value2, context) => {
      setInnerValue(value2, context);
    };
    const handlePaletteChange = context => {
      props2.onPaletteBarChange(context);
    };
    return {
      baseClassName,
      innerValue,
      visible,
      setVisible,
      setInnerValue,
      handleChange,
      handlePaletteChange
    };
  },
  render() {
    const h = arguments[0];
    const {
      popupProps,
      disabled,
      innerValue,
      baseClassName,
      setVisible,
      handleChange,
      handlePaletteChange
    } = this;
    const renderPopupContent = () => {
      if (disabled) return null;
      return h("color-panel", helper([{
        "props": {
          ...{
            ...this.$props,
            value: innerValue
          }
        },
        "attrs": {
          "togglePopup": setVisible
        }
      }, {
        "on": {
          change: handleChange,
          handlePaletteChange
        }
      }, {
        "ref": "refColorPanel"
      }]));
    };
    const popProps = {
      placement: "bottom-left",
      ...(popupProps || {}),
      trigger: "click",
      attach: "body",
      overlayClassName: [baseClassName],
      visible: this.visible,
      overlayInnerStyle: {
        padding: 0
      },
      onVisibleChange: (visible, context) => {
        if (context.trigger === "document") this.setVisible(false);
      }
    };
    return h("t-popup", {
      "props": {
        ...{
          ...popProps
        }
      },
      "attrs": {
        "content": renderPopupContent
      }
    }, [h("div", {
      "class": `${baseClassName}__trigger`,
      "on": {
        "click": () => setVisible(!this.visible)
      }
    }, [renderLNodeJSXDefault(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
