"use strict";

var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  return mod && mod.__esModule ? mod : {
    "default": mod
  };
};

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

var classnames_1 = __importDefault(require("classnames"));

var perfect_scrollbar_1 = __importDefault(require("perfect-scrollbar"));

require("./style/scrollbar.css");

var prefixCls = 'dmc-scrollbar';
var defaultOpts = {
  suppressScrollX: true,
  minScrollbarLength: 20
};

var createScrollbar = function createScrollbar(dom, type, options, className) {
  var _a, _b;

  if (options === void 0) {
    options = defaultOpts;
  }

  var classes = classnames_1["default"](prefixCls, (_a = {}, _a[prefixCls + "-" + type] = type, _a), className).split(' ');
  dom === null || dom === void 0 ? void 0 : (_b = dom.classList).add.apply(_b, classes);
  var ps = new perfect_scrollbar_1["default"](dom, options);
  return [ps, function () {
    var _a;

    ps === null || ps === void 0 ? void 0 : ps.destroy();
    ps = undefined;
    dom === null || dom === void 0 ? void 0 : (_a = dom.classList).remove.apply(_a, classes);
    dom = undefined;
  }];
};

exports["default"] = createScrollbar;

