var __assign = this && this.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import orderBy from 'lodash/orderBy';
import { randomUuid } from "../_utils/stringUtil";
import { prefixCls } from "./ColorGradient";

var Palette = function Palette(_a) {
  var _b = _a.palette,
      palette = _b === void 0 ? [] : _b;
  var gradientId = React.useMemo(function () {
    return randomUuid();
  }, []);
  return _jsxs("svg", __assign({
    className: prefixCls + "-palette",
    width: "100%",
    height: "100%"
  }, {
    children: [_jsx("defs", {
      children: _jsxs("linearGradient", __assign({
        id: gradientId,
        x1: "0",
        y1: "0.5",
        x2: "1",
        y2: "0.5"
      }, {
        children: [' ', orderBy(palette, 'offset', 'asc').map(function (c, index) {
          return _jsx("stop", {
            offset: c.offset,
            style: {
              stopColor: c.color,
              stopOpacity: 1
            }
          }, index);
        })]
      }), void 0)
    }, void 0), _jsx("rect", {
      x: "0",
      y: "0",
      width: "100%",
      height: "100%",
      fill: "url(#" + gradientId + ")"
    }, void 0)]
  }), void 0);
};

Palette.displayName = 'Palette';
export default Palette;
var PaletteMemo = /*#__PURE__*/React.memo(Palette);
PaletteMemo.displayName = 'PaletteMemo';
export { PaletteMemo };

