function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import updateStyle from "./updateStyle";

// 内库使用-start
import LocaleUtil from "./../../../../utils/LocaleUtil";
// 内库使用-end

/* 测试使用-start
import { LocaleUtil } from 'seedsui-react'
测试使用-start */

// 更新属性
function updateAttribute(mask, _ref) {
  var portal = _ref.portal,
    maskClosable = _ref.maskClosable,
    onVisibleChange = _ref.onVisibleChange,
    maskProps = _ref.maskProps,
    title = _ref.title,
    titleProps = _ref.titleProps,
    content = _ref.content,
    contentProps = _ref.contentProps,
    footerProps = _ref.footerProps,
    ok = _ref.ok,
    onOk = _ref.onOk,
    okProps = _ref.okProps,
    cancel = _ref.cancel,
    onCancel = _ref.onCancel,
    cancelProps = _ref.cancelProps;
  // 更新遮罩
  updateStyle(mask, _objectSpread(_objectSpread({}, maskProps), {}, {
    baseClassName: 'mask modal-mask'
  }));

  // 更新标题
  var titleDOM = mask.querySelector('.modal-title');
  updateStyle(titleDOM, _objectSpread(_objectSpread({}, titleProps), {}, {
    baseClassName: 'modal-title'
  }));
  if (title) {
    var _titleDOM$classList, _titleDOM$classList$r;
    titleDOM === null || titleDOM === void 0 || (_titleDOM$classList = titleDOM.classList) === null || _titleDOM$classList === void 0 || (_titleDOM$classList$r = _titleDOM$classList.remove) === null || _titleDOM$classList$r === void 0 || _titleDOM$classList$r.call(_titleDOM$classList, 'hide');
    titleDOM.innerHTML = title;
  } else {
    var _titleDOM$classList2, _titleDOM$classList2$;
    titleDOM === null || titleDOM === void 0 || (_titleDOM$classList2 = titleDOM.classList) === null || _titleDOM$classList2 === void 0 || (_titleDOM$classList2$ = _titleDOM$classList2.add) === null || _titleDOM$classList2$ === void 0 || _titleDOM$classList2$.call(_titleDOM$classList2, 'hide');
  }

  // 更新内容
  var contentDOM = mask.querySelector('.modal-content');
  updateStyle(contentDOM, _objectSpread(_objectSpread({}, contentProps), {}, {
    baseClassName: 'modal-content'
  }));
  if (content) {
    contentDOM.innerHTML = content;
  } else {
    contentDOM.innerHTML = '';
  }

  // 更新底部
  var footerDOM = mask.querySelector('.modal-footer');
  updateStyle(footerDOM, _objectSpread(_objectSpread({}, footerProps), {}, {
    baseClassName: 'modal-footer'
  }));

  // 提交按钮
  var okDOM = mask.querySelector('.modal-ok');
  updateStyle(okDOM, _objectSpread(_objectSpread({}, okProps), {}, {
    baseClassName: 'modal-ok'
  }));
  okDOM.innerHTML = ok || LocaleUtil.locale('确定', 'SeedsUI_ok');

  // 取消按钮
  var cancelDOM = mask.querySelector('.modal-cancel');
  updateStyle(cancelDOM, _objectSpread(_objectSpread({}, cancelProps), {}, {
    baseClassName: 'modal-cancel'
  }));
  cancelDOM.innerHTML = cancel || LocaleUtil.locale('取消', 'SeedsUI_cancel');
  if (cancel === null) {
    var _cancelDOM$classList, _cancelDOM$classList$;
    cancelDOM === null || cancelDOM === void 0 || (_cancelDOM$classList = cancelDOM.classList) === null || _cancelDOM$classList === void 0 || (_cancelDOM$classList$ = _cancelDOM$classList.add) === null || _cancelDOM$classList$ === void 0 || _cancelDOM$classList$.call(_cancelDOM$classList, 'hide');
  } else {
    var _cancelDOM$classList2, _cancelDOM$classList3;
    cancelDOM === null || cancelDOM === void 0 || (_cancelDOM$classList2 = cancelDOM.classList) === null || _cancelDOM$classList2 === void 0 || (_cancelDOM$classList3 = _cancelDOM$classList2.remove) === null || _cancelDOM$classList3 === void 0 || _cancelDOM$classList3.call(_cancelDOM$classList2, 'hide');
  }

  // 更新事件中用到的属性（否则事件中将永远读取到的是闭包中的属性，即上次的属性）
  mask.maskClosable = maskClosable;
  mask.onOk = onOk;
  mask.onCancel = onCancel;
  mask.onVisibleChange = onVisibleChange;

  // dom透传
  if (toString.call(portal).indexOf('HTML') !== -1) {
    portal.appendChild(mask);
  } else {
    ;
    (document.getElementById('root') || document.body).appendChild(mask);
  }
}
export default updateAttribute;