/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

'use strict';

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

var helper = require('../../chunks/helper.js');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var hooks_useVmodel = require('../../hooks/use-vmodel.js');
var utils_renderNode = require('../../utils/render-node.js');
var components_colorPicker_props = require('./props.js');
var components_popup_index = require('../popup/index.js');
var components_colorPicker_panel_index = require('./panel/index.js');
var components_colorPicker_trigger = require('./trigger.js');
var components_colorPicker_hooks_index = require('./hooks/index.js');
require('@babel/runtime/helpers/typeof');
require('vue');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../popup/props.js');
require('../popup/container.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('lodash');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('../../utils/map-props.js');
require('../../utils/with-install.js');
require('../../config.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../config-provider/useConfig.js');
require('../../hooks/use-common-classname.js');
require('../../chunks/constants.js');
require('./panel/header.js');
require('../radio/index.js');
require('../radio/radio.js');
require('../radio/props.js');
require('../../utils/event.js');
require('../radio/group.js');
require('lodash/isNumber');
require('../radio/radio-button.js');
require('./panel/linear-gradient.js');
require('lodash/cloneDeep');
require('../../chunks/color.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('../../chunks/defineProperty-28395935.js');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('@ldesign/icons-vue');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../../chunks/helper2.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/plugin.js');
require('../button/props.js');
require('../../utils/ripple.js');
require('../input/index.js');
require('../input/input.js');
require('../input/props.js');
require('../input/group.js');
require('../input-number/props.js');
require('../input-number/hooks/use-input-number.js');
require('../../chunks/isObjectLike-2443c6ff.js');
require('../../chunks/_commonjsHelpers-ea2bee21.js');
require('../../chunks/isArray-b0f0e351.js');
require('../../chunks/log.js');
require('../../hooks/use-form-disabled.js');
require('../../hooks/use-global-icon.js');
require('./panel/base-props.js');
require('./panel/saturation.js');
require('../select/index.js');
require('../select/select.js');
require('lodash/isFunction');
require('lodash/debounce');
require('lodash/get');
require('lodash/isArray');
require('../../hooks/use-default-value.js');
require('../../hooks/lnode.js');
require('lodash/isEmpty');
require('../../hooks/render-lnode.js');
require('lodash/isObject');
require('../select/props.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/hooks/use-single.js');
require('lodash/pick');
require('../../hooks/use-config.js');
require('../select-input/hooks/use-multiple.js');
require('../select-input/hooks/use-overlay-innerstyle.js');
require('../common/fake-arrow.js');
require('../select/option.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('lodash/intersection');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../../hooks/use-lazy-load.js');
require('../../chunks/observe.js');
require('../select/utils.js');
require('../select/select-panel.js');
require('../../hooks/use-virtual-scroll.js');
require('../select/hooks/use-select-options.js');
require('../select/option-group.js');
require('../../chunks/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('./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 = VueCompositionAPI.defineComponent({
  name: "LColorPicker",
  components: {
    LPopup: components_popup_index.Popup,
    ColorPanel: components_colorPicker_panel_index["default"],
    DefaultTrigger: components_colorPicker_trigger["default"]
  },
  props: _objectSpread({}, components_colorPicker_props["default"]),
  setup: function setup(props2) {
    var baseClassName = components_colorPicker_hooks_index.useBaseClassName();
    var visible = VueCompositionAPI.ref(false);

    var setVisible = function setVisible(value2) {
      return visible.value = value2;
    };

    var _toRefs = VueCompositionAPI.toRefs(props2),
        value = _toRefs.value;

    var _useVModel = hooks_useVmodel["default"](value, props2.defaultValue, props2.onChange, "change"),
        _useVModel2 = _slicedToArray__default["default"](_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.helper([{
        "props": _objectSpread({}, _objectSpread(_objectSpread({}, _this.$props), {}, {
          value: innerValue
        })),
        "attrs": {
          "togglePopup": setVisible
        }
      }, {
        "on": {
          change: handleChange,
          handlePaletteChange: handlePaletteChange
        }
      }, {
        "ref": "refColorPanel"
      }]));
    };

    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 h("l-popup", {
      "props": _objectSpread({}, _objectSpread({}, popProps)),
      "attrs": {
        "content": renderPopupContent
      }
    }, [h("div", {
      "class": "".concat(baseClassName, "__trigger"),
      "on": {
        "click": function click() {
          return setVisible(!_this.visible);
        }
      }
    }, [utils_renderNode.renderLNodeJSXDefault(this, "default", h("default-trigger", {
      "attrs": {
        "color": this.innerValue,
        "disabled": disabled,
        "input-props": this.inputProps,
        "handleTriggerChange": this.setInnerValue
      }
    }))])]);
  }
});

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