import "core-js/modules/es6.regexp.split";
import _Array$isArray from "@babel/runtime-corejs2/core-js/array/is-array";
import "core-js/modules/web.dom.iterable";
import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import "core-js/modules/es6.string.fixed";
import "core-js/modules/es6.array.sort";
import Checkbox from '../checkbox';
import Radio from '../radio';
import Row from './row';
import Intact from 'intact-angular';
import Column from './column';
import { noop, isStringOrNumber, getTextByChildren, getRestProps, mapChildren } from '../utils';
import Spin from '../spin';
import Affix from '../affix';
import Tooltip from '../tooltip';
import Icon from '../icon';
import Button from '../button';
export default function (obj, _Vdt, blocks, $callee) {
  var _this = this,
      _classNameObj;

  _Vdt || (_Vdt = Vdt);
  obj || (obj = {});
  blocks || (blocks = {});
  var h = _Vdt.miss.h,
      hc = _Vdt.miss.hc,
      hu = _Vdt.miss.hu,
      widgets = this && this.widgets || {},
      _blocks = {},
      __blocks = {},
      __u = _Vdt.utils,
      extend = __u.extend,
      _e = __u.error,
      _className = __u.className,
      __slice = __u.slice,
      __noop = __u.noop,
      __m = __u.map,
      __o = __u.Options,
      _getModel = __o.getModel,
      _setModel = __o.setModel,
      _setCheckboxModel = __u.setCheckboxModel,
      _detectCheckboxChecked = __u.detectCheckboxChecked,
      _setSelectModel = __u.setSelectModel,
      self = this.data,
      $this = this,
      scope = obj,
      Animate = self && self.Animate,
      parent = ($callee || {})._super;
  var normalize = Intact.normalize;

  var _self$get = self.get(),
      checkType = _self$get.checkType,
      scheme = _self$get.scheme,
      checkedKeys = _self$get.checkedKeys,
      data = _self$get.data,
      rowKey = _self$get.rowKey,
      className = _self$get.className,
      fixHeader = _self$get.fixHeader,
      noDataTemplate = _self$get.noDataTemplate,
      disableRow = _self$get.disableRow,
      resizable = _self$get.resizable,
      expandedKeys = _self$get.expandedKeys,
      type = _self$get.type,
      _isSticky = _self$get._isSticky,
      stickHeader = _self$get.stickHeader,
      stripe = _self$get.stripe,
      style = _self$get.style,
      rowClassName = _self$get.rowClassName,
      children = _self$get.children,
      sort = _self$get.sort,
      group = _self$get.group,
      _scrollBarWidth = _self$get._scrollBarWidth,
      _scrollPosition = _self$get._scrollPosition,
      _hoverIndex = _self$get._hoverIndex,
      tooltipPosition = _self$get.tooltipPosition,
      _paddingBottom = _self$get._paddingBottom,
      _isStickyScrollbar = _self$get._isStickyScrollbar,
      stickScrollbar = _self$get.stickScrollbar,
      loading = _self$get.loading,
      _isShowLeftRightMiddle = _self$get._isShowLeftRightMiddle,
      merge = _self$get.merge,
      childrenKey = _self$get.childrenKey,
      indent = _self$get.indent;
  /* const {_hoverIndex} = self; */

  /**
   * we must render the children of invisible cell, because it may change the height
   */


  var isInvisible = function isInvisible(onlyLeft, onlyRight, props) {
    return props.fixed !== 'left' && onlyLeft || props.fixed !== 'right' && onlyRight;
  };

  var cols;
  var currentVNode;

  var _scheme;

  var maxRows = 0;
  var maxCols = 0;
  var hasFixedLeft;
  var hasFixedRight;
  self.leftColumns = [];
  self.rightColumns = [];

  var TheadCreator = function TheadCreator(_ref) {
    var onlyLeft = _ref.onlyLeft,
        onlyRight = _ref.onlyRight,
        refContainer = _ref.refContainer,
        style = _ref.style;
    var keys = {};

    var refLeftElement = function refLeftElement(i) {
      return i && self.leftColumns.push(i);
    };

    var refLeft = function refLeft(i) {
      return i && self.leftColumns.push(i.element);
    };

    var refRight = function refRight(i) {
      return i && self.rightColumns.push(i.element);
    };

    var ref = onlyLeft ? refLeft : onlyRight ? refRight : undefined;
    var tableColumns = [];
    cols = [];
    _scheme = {};
    var checkVNode;

    if (checkType === 'checkbox' || checkType === 'radio') {
      maxCols++;
      cols.push(h('col', {
        'style': function () {
          try {
            return {
              width: self._getHeaderWidth('_$checked')
            };
          } catch (e) {
            _e(e);
          }
        }.call($this)
      }, null, 'k-th-check'));
      checkVNode = currentVNode = h('th', {
        'minWidth': function () {
          try {
            return 40;
          } catch (e) {
            _e(e);
          }
        }.call($this)
      }, function () {
        try {
          return checkType === 'checkbox';
        } catch (e) {
          _e(e);
        }
      }.call($this) ? h(Checkbox, {
        'value': function () {
          try {
            return self.isCheckAll();
          } catch (e) {
            _e(e);
          }
        }.call($this),
        '_context': $this,
        'ev-click': function () {
          try {
            return self._toggleCheckAll;
          } catch (e) {
            _e(e);
          }
        }.call($this)
      }) : undefined, _className(function () {
        try {
          return {
            'k-invisible': onlyRight
          };
        } catch (e) {
          _e(e);
        }
      }.call($this)), '_$checked', function () {
        try {
          return onlyLeft ? refLeftElement : undefined;
        } catch (e) {
          _e(e);
        }
      }.call($this));
      tableColumns[0] = [checkVNode];
    }

    var beforeLoop = function beforeLoop(layer) {
      if (layer + 1 > maxRows) maxRows = layer + 1;
      if (!tableColumns[layer]) tableColumns[layer] = [];
    };

    var loop = function loop(item, key, parent, layer, fixed, loopRecursiveCallback) {
      if (!__u.isObject(item) || item.type
      /* is vNode */
      ) {
          item = {
            title: item
          };
        }

      item.key = key; // if parent fixed, fix children

      if (fixed) {
        item.fixed = fixed;
      }

      var dragStart = self._dragStart;

      if (item.fixed === 'left') {
        hasFixedLeft = true;
      } else if (item.fixed === 'right') {
        hasFixedRight = true;
      }

      var invisible = isInvisible(onlyLeft, onlyRight, item);
      var vNode = h(Column, _Object$assign({}, function () {
        try {
          return item;
        } catch (e) {
          _e(e);
        }
      }.call($this), {
        '$parent': function () {
          try {
            return self;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'invisible': function () {
          try {
            return invisible;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'className': _className(function () {
          try {
            return item.className;
          } catch (e) {
            _e(e);
          }
        }.call($this)),
        'ref': function () {
          try {
            return !invisible ? ref : undefined;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'prevVNode': function () {
          try {
            return currentVNode;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'cols': function () {
          try {
            return 0;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        '_context': $this,
        'value': _getModel(self, function () {
          try {
            return "group." + key;
          } catch (e) {
            _e(e);
          }
        }.call($this)),
        'ev-click': function () {
          try {
            return item.sortable ? self._sort.bind(self, key, item) : undefined;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'ev-dragStart': function () {
          try {
            return dragStart;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'ev-$change:value': function ev$changeValue(__c, __n) {
          _setModel(self, function () {
            try {
              return "group." + key;
            } catch (e) {
              _e(e);
            }
          }.call($this), __n, $this);
        }
      }));
      tableColumns[layer].push(vNode);
      var props = vNode.props;

      if (loopRecursiveCallback(item, props, layer + 1, item.fixed)) {
        props.rows = 1;
      } else {
        currentVNode = vNode;

        if (/^\d+$/.test(key)) {
          // avoid digital key
          _e(new Error("don't use digits as key: " + key + "."));
        } else if (_scheme[key]) {
          _e(new Error("reduplicated key: " + key));
        }

        cols.push(h('col', {
          'width': function () {
            try {
              return item.width;
            } catch (e) {
              _e(e);
            }
          }.call($this),
          'style': function () {
            try {
              return {
                width: self._getHeaderWidth(key)
              };
            } catch (e) {
              _e(e);
            }
          }.call($this)
        }, null, _className(function () {
          try {
            var _ref2;

            return _ref2 = {}, _ref2[item.className] = item.className, _ref2;
          } catch (e) {
            _e(e);
          }
        }.call($this))));
        props.cols = 1;
        maxCols++;
        Object.defineProperty(props, 'rows', {
          get: function get() {
            return maxRows - layer;
          },
          enumerable: true
        }); // add leaf node to _scheme

        _scheme[key] = props;
      }

      if (parent) {
        parent.cols += props.cols; // if child fixed and it will not be invisible
        // parent must not be invisible too

        if (!props.invisible) {
          parent.invisible = false;
        }
      }
    };

    var loopScheme = function loopScheme(scheme, parent, layer, fixed) {
      var ret = false;
      beforeLoop(layer);

      __u.map(scheme, function (item, key) {
        ret = true;
        loop(item, key, parent, layer, fixed, function (item, props, layer, fixed) {
          if (item.scheme) {
            return loopScheme(item.scheme, props, layer, fixed);
          }

          return false;
        });
      });

      return ret;
    };

    var loopColumn = function loopColumn(children, parent, layer, fixed) {
      // add a flag, when we enter to the map callback set it to true
      // because it may have children but is not Column
      var ret = false;
      var beforeLoopDone = false;
      mapChildren(children, function (vNode) {
        if (vNode.tag === Column) {
          if (!beforeLoopDone) {
            beforeLoop(layer);
            beforeLoopDone = true;
          }

          ret = true;
          var props = vNode.props;
          var blockFn = props._blocks && (props._blocks.default || props._blocks.template);

          var _props = _Object$assign({}, props, {
            template: props.template || blockFn && function () {
              for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
                args[_key] = arguments[_key];
              }

              return blockFn.call.apply(blockFn, [_this, noop].concat(args));
            }
          });

          loop(_props, props.key, parent, layer, fixed, function (item, props, layer, fixed) {
            if (item.children) {
              return loopColumn(item.children, props, layer, fixed);
            }

            return false;
          });
        }
      });
      return ret;
    };

    loopScheme(scheme, null, 0); // for using TableColumn as children

    loopColumn(children, null, 0); // set checkVNode's rowspan

    if (maxRows > 1 && checkVNode) {
      checkVNode.props.rowspan = maxRows;
    }

    var thead = h('div', {
      'style': function () {
        try {
          return onlyLeft ? {
            width: self.get('_leftWidth') + 'px'
          } : onlyRight ? {
            width: self.get('_rightWidth') + 'px'
          } : void 0;
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, h('div', {
      'style': function () {
        try {
          return {
            paddingRight: self.get('_padding') + 'px'
          };
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, h('table', {
      'style': function () {
        try {
          return style;
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, [h('colgroup', null, function () {
      try {
        return cols;
      } catch (e) {
        _e(e);
      }
    }.call($this)), h('thead', null, __m(function () {
      try {
        return tableColumns;
      } catch (e) {
        _e(e);
      }
    }.call($this), function (value, key) {
      return h('tr', null, function () {
        try {
          return value;
        } catch (e) {
          _e(e);
        }
      }.call($this));
    }, $this))]), 'k-thead-wrapper'), 'k-thead', null, function () {
      try {
        return refContainer;
      } catch (e) {
        _e(e);
      }
    }.call($this));
    return _isSticky ? h(Affix, {
      'top': function () {
        try {
          return stickHeader === true ? 0 : +stickHeader;
        } catch (e) {
          _e(e);
        }
      }.call($this),
      'exclude': function () {
        try {
          return self._excludeStickHeader;
        } catch (e) {
          _e(e);
        }
      }.call($this),
      'children': function () {
        try {
          return thead;
        } catch (e) {
          _e(e);
        }
      }.call($this),
      '_context': $this
    }) : thead;
  };

  var TbodyCreator = function TbodyCreator(_ref3) {
    var onlyLeft = _ref3.onlyLeft,
        onlyRight = _ref3.onlyRight,
        refContainer = _ref3.refContainer,
        refTable = _ref3.refTable,
        style = _ref3.style;
    // save the rowspan and colspan information
    var grid = [];
    var rows;

    if (!data || !data.length) {
      rows = h('tr', null, h('td', {
        'colspan': function () {
          try {
            return maxCols;
          } catch (e) {
            _e(e);
          }
        }.call($this)
      }, (_blocks['no-data'] = function (parent) {
        return function () {
          try {
            return normalize ? normalize(noDataTemplate) : noDataTemplate;
          } catch (e) {
            _e(e);
          }
        }.call($this);
      }) && (__blocks['no-data'] = function (parent) {
        var args = arguments;
        return blocks['no-data'] ? blocks['no-data'].apply($this, [function () {
          return _blocks['no-data'].apply($this, args);
        }].concat(__slice.call(args, 1))) : _blocks['no-data'].apply($this, args);
      }) && __blocks['no-data'].apply($this, [__noop]), 'k-no-data'), null, 'table_no_data');
    } else {
      var index = 0;
      rows = [];

      var loop = function loop(data, level, hidden) {
        data.forEach(function (value) {
          var children = childrenKey && _Array$isArray(value[childrenKey]) ? value[childrenKey] : null;
          var rowInGrid = [];
          var columnIndex = -1;

          if (merge) {
            grid.push(rowInGrid);
          }

          var key = rowKey.call(self, value, index);
          var disabled = disableRow.call(self, value, index, key);
          var className = rowClassName.call(self, value, index, key);
          var spreaded = self.isSpreaded(key);
          var tr = h(Row, {
            'key': function () {
              try {
                return key;
              } catch (e) {
                _e(e);
              }
            }.call($this),
            'className': _className(function () {
              try {
                var _ref4;

                return _ref4 = {
                  'k-disabled': disabled
                }, _ref4[className] = className, _ref4['k-checked'] = self.isChecked(key), _ref4['k-hover'] = _hoverIndex === index, _ref4['k-selected'] = !disabled && self.isSelected(key), _ref4['k-spread'] = spreaded, _ref4['k-hidden'] = hidden, _ref4;
              } catch (e) {
                _e(e);
              }
            }.call($this)),
            'children': [function () {
              try {
                return checkType === 'checkbox';
              } catch (e) {
                _e(e);
              }
            }.call($this) ? h('td', null, h(Checkbox, {
              'name': 'k-table-checkbox',
              'trueValue': function () {
                try {
                  return key;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'disabled': function () {
                try {
                  return disabled;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              '_context': $this,
              'value': _getModel(self, 'checkedKeys'),
              'ev-$change:value': function ev$changeValue(__c, __n) {
                _setModel(self, 'checkedKeys', __n, $this);
              }
            }), _className(function () {
              try {
                return {
                  "k-th-check": true,
                  'k-invisible': onlyRight
                };
              } catch (e) {
                _e(e);
              }
            }.call($this))) : function () {
              try {
                return checkType === 'radio';
              } catch (e) {
                _e(e);
              }
            }.call($this) ? h('td', null, h(Radio, {
              'name': 'k-table-radio',
              'trueValue': function () {
                try {
                  return key;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'disabled': function () {
                try {
                  return disabled;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              '_context': $this,
              'value': _getModel(self, 'checkedKey'),
              'ev-$change:value': function ev$changeValue(__c, __n) {
                _setModel(self, 'checkedKey', __n, $this);
              }
            }), _className(function () {
              try {
                return {
                  "k-th-check": true,
                  'k-invisible': onlyRight
                };
              } catch (e) {
                _e(e);
              }
            }.call($this))) : undefined, function () {
              try {
                return __u.map(_scheme, function (item, schemeKey) {
                  columnIndex++;
                  var spans;

                  if (merge) {
                    if (columnIndex > 0) {
                      var prevCell = rowInGrid[columnIndex - 1];

                      if (prevCell && prevCell.colspan > 1) {
                        var current = {
                          rowspan: prevCell.rowspan,
                          colspan: prevCell.colspan - 1
                        };
                        rowInGrid.push(current);
                        return;
                      }
                    }

                    if (index > 0) {
                      var prevRow = grid[index - 1];
                      var aboveCell = prevRow[columnIndex];

                      if (aboveCell && aboveCell.rowspan > 1) {
                        var _current = {
                          rowspan: aboveCell.rowspan - 1,
                          colspan: aboveCell.colspan
                        };
                        rowInGrid.push(_current);
                        return;
                      }
                    }

                    spans = merge.call(self, value, item, index, columnIndex);
                    rowInGrid.push(spans);
                  }

                  var td;

                  if (item.template) {
                    if (typeof item.template === 'function') {
                      td = item.template.call(self, value, index); // for Intact-Vue

                      if (normalize) {
                        td = normalize(td);
                      }
                    } else {
                      td = item.template;
                    }
                  } else if (value[schemeKey] !== undefined) {
                    td = value[schemeKey];
                  } else {
                    var _obj = value,
                        keys = schemeKey.split('.'),
                        i = 0;

                    while (_obj != null && i < keys.length) {
                      _obj = _obj[keys[i++]];
                    }

                    td = i && i === keys.length ? _obj : null;
                  }

                  return h('td', _Object$assign({
                    'title': function () {
                      try {
                        return getTextByChildren(td) || undefined;
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this),
                    'data-ignore': function () {
                      try {
                        return item.ignore ? '' : undefined;
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this)
                  }, function () {
                    try {
                      return spans;
                    } catch (e) {
                      _e(e);
                    }
                  }.call($this), {
                    'style': function () {
                      try {
                        return {
                          paddingLeft: columnIndex === 0 && level ? level * indent + 'px' : undefined
                        };
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this)
                  }), [function () {
                    try {
                      return columnIndex === 0 && children;
                    } catch (e) {
                      _e(e);
                    }
                  }.call($this) ? h(Button, {
                    'type': 'none',
                    'icon': function () {
                      try {
                        return true;
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this),
                    'circle': function () {
                      try {
                        return true;
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this),
                    'size': 'mini',
                    'className': 'k-table-arrow',
                    'children': h(Icon, {
                      'className': 'ion-ios-arrow-right',
                      'size': 'small',
                      '_context': $this
                    }),
                    '_context': $this,
                    'ev-click': function () {
                      try {
                        return self._toggleSpreadRow.bind(self, key);
                      } catch (e) {
                        _e(e);
                      }
                    }.call($this)
                  }) : undefined, function () {
                    try {
                      return typeof td === 'boolean' ? String(td) : td;
                    } catch (e) {
                      _e(e);
                    }
                  }.call($this)], _className(function () {
                    try {
                      var _ref5;

                      return _ref5 = {
                        'k-invisible': isInvisible(onlyLeft, onlyRight, item)
                      }, _ref5["k-" + item.align] = item.align, _ref5[item.className] = item.className, _ref5;
                    } catch (e) {
                      _e(e);
                    }
                  }.call($this)));
                });
              } catch (e) {
                _e(e);
              }
            }.call($this)],
            '_context': $this,
            'ev-click': function () {
              try {
                return self._clickRow.bind(self, value, index, key);
              } catch (e) {
                _e(e);
              }
            }.call($this),
            'ev-$destroyed': function () {
              try {
                return self._onRowDestroyed.bind(self, key);
              } catch (e) {
                _e(e);
              }
            }.call($this),
            'ev-mouseenter': function () {
              try {
                return self._onRowEnter.bind(self, index);
              } catch (e) {
                _e(e);
              }
            }.call($this),
            'ev-mouseleave': function () {
              try {
                return self._onRowLeave;
              } catch (e) {
                _e(e);
              }
            }.call($this)
          }); // add tooltip

          if (blocks.tooltip) {
            var content = (_blocks['tooltip'] = function (parent) {
              return null;
            }) && (__blocks['tooltip'] = function (parent) {
              var args = arguments;
              return blocks['tooltip'] ? blocks['tooltip'].apply($this, [function () {
                return _blocks['tooltip'].apply($this, args);
              }].concat(__slice.call(args, 1))) : _blocks['tooltip'].apply($this, args);
            }) && __blocks['tooltip'].apply($this, [__noop].concat(function () {
              try {
                return [value, index];
              } catch (e) {
                _e(e);
              }
            }.call($this)));

            tr = h(Tooltip, {
              'position': function () {
                try {
                  return tooltipPosition;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'children': function () {
                try {
                  return tr;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              '_context': $this,
              '_blocks': function (blocks) {
                var _blocks = {},
                    __blocks = extend({}, blocks);

                return (_blocks['content'] = function (parent) {
                  return function () {
                    try {
                      return content;
                    } catch (e) {
                      _e(e);
                    }
                  }.call($this);
                }) && (__blocks['content'] = function (parent) {
                  var args = arguments;
                  return blocks['content'] ? blocks['content'].apply($this, [function () {
                    return _blocks['content'].apply($this, args);
                  }].concat(__slice.call(args, 1))) : _blocks['content'].apply($this, args);
                }), __blocks;
              }.call($this, {})
            });
          }

          if (blocks.expand && expandedKeys.indexOf(key) > -1) {
            tr = [tr, h('tr', null, h('td', {
              'colspan': function () {
                try {
                  return maxCols;
                } catch (e) {
                  _e(e);
                }
              }.call($this)
            }, (_blocks['expand'] = function (parent) {
              return null;
            }) && (__blocks['expand'] = function (parent) {
              var args = arguments;
              return blocks['expand'] ? blocks['expand'].apply($this, [function () {
                return _blocks['expand'].apply($this, args);
              }].concat(__slice.call(args, 1))) : _blocks['expand'].apply($this, args);
            }) && __blocks['expand'].apply($this, [__noop].concat(function () {
              try {
                return [value, index];
              } catch (e) {
                _e(e);
              }
            }.call($this)))), 'k-expand', function () {
              try {
                return key + ".expand";
              } catch (e) {
                _e(e);
              }
            }.call($this))];
          }

          index++;
          rows.push(tr); // for tree table

          if (children) {
            loop(value[childrenKey], level + 1, hidden || !spreaded);
          }
        });
      };

      loop(data, 0, false);
    }

    var tbody = h('tbody', null, function () {
      try {
        return rows;
      } catch (e) {
        _e(e);
      }
    }.call($this));
    return h('div', {
      'style': function () {
        try {
          var _style;

          return !_isSticky && (typeof fixHeader === 'number' || typeof fixHeader === 'string') ? _style = {
            maxHeight: fixHeader - (onlyLeft || onlyRight ? _paddingBottom : 0) + "px"
          } : void 0, _style;
        } catch (e) {
          _e(e);
        }
      }.call($this),
      'ev-scroll': function () {
        try {
          return self._onTBodyScroll;
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, h('table', {
      'style': function () {
        try {
          return style;
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, [h('colgroup', null, function () {
      try {
        return cols;
      } catch (e) {
        _e(e);
      }
    }.call($this)), function () {
      try {
        return tbody;
      } catch (e) {
        _e(e);
      }
    }.call($this)], null, null, function () {
      try {
        return refTable;
      } catch (e) {
        _e(e);
      }
    }.call($this)), 'k-tbody', null, function () {
      try {
        return refContainer;
      } catch (e) {
        _e(e);
      }
    }.call($this));
  };

  var table = h('div', null, [h(TheadCreator, {
    'refContainer': function () {
      try {
        return function (dom) {
          return self.header = dom;
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.tableWidth
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  }), h(TbodyCreator, {
    'refContainer': function () {
      try {
        return function (dom) {
          return self.scroll = dom;
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'refTable': function () {
      try {
        return function (dom) {
          return self.table = dom;
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.tableWidth
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  })], 'k-table-wrapper');
  self.hasFixedLeft = hasFixedLeft;
  self.hasFixedRight = hasFixedRight;
  var classNameObj = (_classNameObj = {
    'k-table': true
  }, _classNameObj[className] = className, _classNameObj["k-" + type] = type !== 'default', _classNameObj['k-sticky'] = _isSticky, _classNameObj["k-scroll-" + _scrollPosition] = _isShowLeftRightMiddle, _classNameObj['k-sticky-scrollbar'] = _isStickyScrollbar, _classNameObj['k-stripe'] = stripe, _classNameObj['k-fluid-height'] = fixHeader === true, _classNameObj);
  return h('div', _Object$assign({}, function () {
    try {
      return getRestProps(self);
    } catch (e) {
      _e(e);
    }
  }.call($this)), [function () {
    try {
      return table;
    } catch (e) {
      _e(e);
    }
  }.call($this), function () {
    try {
      return hasFixedLeft;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', {
    'style': function () {
      try {
        return {
          width: self.get('_leftWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, [h(TheadCreator, {
    'onlyLeft': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.get('_tableWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  }), h(TbodyCreator, {
    'onlyLeft': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.get('_tableWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'refContainer': function () {
      try {
        return function (i) {
          return self.leftFixedScroll = i;
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  })], 'k-table-wrapper k-fixed-left') : undefined, function () {
    try {
      return hasFixedRight;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', {
    'style': function () {
      try {
        return {
          width: self.get('_rightWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, [h(TheadCreator, {
    'onlyRight': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.get('_tableWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  }), h(TbodyCreator, {
    'onlyRight': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return {
          width: self.get('_tableWidth') + 'px'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'refContainer': function () {
      try {
        return function (i) {
          return self.rightFixedScroll = i;
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  })], 'k-table-wrapper k-fixed-right') : undefined, function () {
    try {
      return _isStickyScrollbar;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h(Affix, {
    'bottom': function () {
      try {
        return stickScrollbar === true ? 0 : +stickScrollbar;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'shouldFix': function () {
      try {
        return self._shouldStickScrollbar;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'style': function () {
      try {
        return self.get('_stickyScrollbarStyle');
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'children': h('div', {
      'ev-scroll': function () {
        try {
          return self._onTBodyScroll;
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, h('div', {
      'style': function () {
        try {
          return {
            width: self.get('_tableWidth') + 'px'
          };
        } catch (e) {
          _e(e);
        }
      }.call($this)
    }, null, 'k-inner'), 'k-scrollbar', null, function (i) {
      widgets['scrollbar'] = i;
    }),
    '_context': $this
  }) : undefined, function () {
    try {
      return loading;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h(Spin, {
    'overlay': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'size': 'small',
    '_context': $this
  }) : undefined], _className(function () {
    try {
      return classNameObj;
    } catch (e) {
      _e(e);
    }
  }.call($this)));
}