"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _vue = require("vue");
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _context = require("./context");
var _divider = _interopRequireDefault(require("../divider"));
var _PanelPicker = _interopRequireDefault(require("./components/PanelPicker"));
var _PanelPresets = _interopRequireDefault(require("./components/PanelPresets"));
var ColorPickerPanel = (0, _vue.defineComponent)({
  name: 'ColorPickerPanel',
  inheritAttrs: false,
  props: ['prefixCls', 'presets', 'onChange', 'onClear', 'color', 'panelRender', 'formatOptions'],
  setup: function setup(props, _ref) {
    var attrs = _ref.attrs;
    var colorPickerPanelPrefixCls = (0, _vue.computed)(function () {
      return "".concat(props.prefixCls, "-inner-content");
    });
    // ==== Inject props ===
    var panelPickerProps = (0, _vue.computed)(function () {
      return (0, _objectSpread2.default)({
        prefixCls: props.prefixCls,
        value: props.color,
        formatOptions: props.formatOptions,
        onChange: props.onChange,
        onClear: props.onClear
      }, attrs);
    });
    var panelPresetsProps = (0, _vue.computed)(function () {
      return {
        prefixCls: props.prefixCls,
        value: props.color,
        presets: props.presets,
        onChange: props.onChange
      };
    });
    // ==== Inject ===
    (0, _vue.provide)(_context.PanelPickerContext, panelPickerProps);
    (0, _vue.provide)(_context.PanelPresetsContext, panelPresetsProps);
    // ==== Render ===
    var innerPanel = (0, _vue.computed)(function () {
      return (0, _vue.createVNode)(_vue.Fragment, null, [(0, _vue.createVNode)(_PanelPicker.default, null, null), Array.isArray(props.presets) && (0, _vue.createVNode)(_divider.default, {
        "class": "".concat(colorPickerPanelPrefixCls.value, "-divider")
      }, null), (0, _vue.createVNode)(_PanelPresets.default, null, null)]);
    });
    return function () {
      return (0, _vue.createVNode)("div", {
        "class": colorPickerPanelPrefixCls.value
      }, [typeof props.panelRender === 'function' ? props.panelRender(innerPanel.value, {
        components: {
          Picker: _PanelPicker.default,
          Presets: _PanelPresets.default
        }
      }) : innerPanel.value]);
    };
  }
});
var _default = ColorPickerPanel;
exports.default = _default;