import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import Button from '../button';
import Checkbox from '../checkbox';
import Input from '../input';
import { _$, getRestProps } from '../utils';
export default function (obj, _Vdt, blocks, $callee) {
  var _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 _self$get = self.get(),
      data = _self$get.data,
      className = _self$get.className,
      value = _self$get.value,
      keyName = _self$get.keyName,
      leftChecked = _self$get.leftChecked,
      rightChecked = _self$get.rightChecked,
      filterable = _self$get.filterable,
      batchable = _self$get.batchable,
      filter = _self$get.filter,
      label = _self$get.label,
      placeholder = _self$get.placeholder,
      leftTitle = _self$get.leftTitle,
      rightTitle = _self$get.rightTitle,
      selectedKeys = _self$get.selectedKeys,
      enableAdd = _self$get.enableAdd,
      enableRemove = _self$get.enableRemove;

  var classNameObj = (_classNameObj = {
    'k-transfer': true
  }, _classNameObj[className] = className, _classNameObj);

  var Panel = function Panel(props) {
    var keywords = self.get(props.model + "Keywords");
    var data = keywords ? props.data.filter(function (item) {
      return filter(item, keywords);
    }) : props.data;
    return h('div', null, [h('div', null, (_blocks['header'] = function (parent) {
      return [h('div', null, [function () {
        try {
          return self.get(props.model + "Checked.length");
        } catch (e) {
          _e(e);
        }
      }.call($this), ' /\n                    ', function () {
        try {
          return data.length;
        } catch (e) {
          _e(e);
        }
      }.call($this)], 'k-count'), h(Checkbox, {
        'className': 'c-ellipsis',
        'value': function () {
          try {
            return self._isCheckAll(props.model);
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'children': function () {
          try {
            return props.title;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        '_context': $this,
        'ev-click': function () {
          try {
            return self._toggleCheckAll.bind(self, props.model);
          } catch (e) {
            _e(e);
          }
        }.call($this)
      })];
    }) && (__blocks['header'] = function (parent) {
      var args = arguments;
      return blocks['header'] ? blocks['header'].apply($this, [function () {
        return _blocks['header'].apply($this, args);
      }].concat(__slice.call(args, 1))) : _blocks['header'].apply($this, args);
    }) && __blocks['header'].apply($this, [__noop].concat(function () {
      try {
        return [props.model];
      } catch (e) {
        _e(e);
      }
    }.call($this))), 'k-title'), function () {
      try {
        return filterable;
      } catch (e) {
        _e(e);
      }
    }.call($this) ? (_blocks['filter'] = function (parent) {
      return h(Input, {
        'placeholder': function () {
          try {
            return placeholder;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'clearable': function () {
          try {
            return true;
          } catch (e) {
            _e(e);
          }
        }.call($this),
        'size': 'small',
        '_context': $this,
        '_blocks': function (blocks) {
          var _blocks = {},
              __blocks = extend({}, blocks);

          return (_blocks['prefix'] = function (parent) {
            return h('i', null, null, 'ion-ios-search');
          }) && (__blocks['prefix'] = function (parent) {
            var args = arguments;
            return blocks['prefix'] ? blocks['prefix'].apply($this, [function () {
              return _blocks['prefix'].apply($this, args);
            }].concat(__slice.call(args, 1))) : _blocks['prefix'].apply($this, args);
          }), __blocks;
        }.call($this, {}),
        'value': _getModel(self, function () {
          try {
            return props.model + "Keywords";
          } catch (e) {
            _e(e);
          }
        }.call($this)),
        'ev-$change:value': function ev$changeValue(__c, __n) {
          _setModel(self, function () {
            try {
              return props.model + "Keywords";
            } catch (e) {
              _e(e);
            }
          }.call($this), __n, $this);
        }
      });
    }) && (__blocks['filter'] = function (parent) {
      var args = arguments;
      return blocks['filter'] ? blocks['filter'].apply($this, [function () {
        return _blocks['filter'].apply($this, args);
      }].concat(__slice.call(args, 1))) : _blocks['filter'].apply($this, args);
    }) && __blocks['filter'].apply($this, [__noop].concat(function () {
      try {
        return [props.model];
      } catch (e) {
        _e(e);
      }
    }.call($this))) : undefined, h(Animate, {
      'className': 'k-list',
      'disabled': function () {
        try {
          return true;
        } catch (e) {
          _e(e);
        }
      }.call($this),
      'children': (_blocks['list'] = function (parent) {
        return __m(function () {
          try {
            return data;
          } catch (e) {
            _e(e);
          }
        }.call($this), function (value, key) {
          return h(Animate, {
            'className': _className(function () {
              try {
                return {
                  "k-item": true,
                  "k-disabled": value.disabled
                };
              } catch (e) {
                _e(e);
              }
            }.call($this)),
            'key': function () {
              try {
                return value[keyName] || value.label || value;
              } catch (e) {
                _e(e);
              }
            }.call($this),
            'a:transition': 'c-fade',
            'children': h(Checkbox, {
              'name': function () {
                try {
                  return props.model;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'trueValue': function () {
                try {
                  return value[keyName];
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'disabled': function () {
                try {
                  return value.disabled;
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'children': (_blocks['label'] = function (parent) {
                return function () {
                  try {
                    return label.call(self, value, key, props.model);
                  } catch (e) {
                    _e(e);
                  }
                }.call($this);
              }) && (__blocks['label'] = function (parent) {
                var args = arguments;
                return blocks['label'] ? blocks['label'].apply($this, [function () {
                  return _blocks['label'].apply($this, args);
                }].concat(__slice.call(args, 1))) : _blocks['label'].apply($this, args);
              }) && __blocks['label'].apply($this, [__noop].concat(function () {
                try {
                  return [value, key, props.model];
                } catch (e) {
                  _e(e);
                }
              }.call($this))),
              '_context': $this,
              'value': _getModel(self, function () {
                try {
                  return props.model + "CheckedKeys";
                } catch (e) {
                  _e(e);
                }
              }.call($this)),
              'ev-click': function () {
                try {
                  return self._onCheckboxChange.bind(self, props.model, key);
                } catch (e) {
                  _e(e);
                }
              }.call($this),
              'ev-$change:value': function ev$changeValue(__c, __n) {
                _setModel(self, function () {
                  try {
                    return props.model + "CheckedKeys";
                  } catch (e) {
                    _e(e);
                  }
                }.call($this), __n, $this);
              }
            }),
            '_context': $this
          });
        }, $this);
      }) && (__blocks['list'] = function (parent) {
        var args = arguments;
        return blocks['list'] ? blocks['list'].apply($this, [function () {
          return _blocks['list'].apply($this, args);
        }].concat(__slice.call(args, 1))) : _blocks['list'].apply($this, args);
      }) && __blocks['list'].apply($this, [__noop].concat(function () {
        try {
          return [props.model];
        } catch (e) {
          _e(e);
        }
      }.call($this))),
      '_context': $this
    })], 'k-panel');
  };

  return h('div', _Object$assign({}, function () {
    try {
      return getRestProps(self);
    } catch (e) {
      _e(e);
    }
  }.call($this)), [h(Panel, {
    'data': function () {
      try {
        return data.filter(function (item) {
          return !~selectedKeys.indexOf(item[keyName]);
        });
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'model': 'left',
    'title': function () {
      try {
        return leftTitle;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  }), h('div', null, [h(Button, {
    'circle': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'icon': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'disabled': function () {
      try {
        return !enableRemove();
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'type': 'primary',
    'size': 'large',
    'children': h('i', null, null, 'k-icon ion-ios-arrow-left'),
    '_context': $this,
    'ev-click': function () {
      try {
        return self._remove;
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }), h(Button, {
    'circle': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'icon': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'disabled': function () {
      try {
        return !enableAdd();
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'type': 'primary',
    'size': 'large',
    'children': h('i', null, null, 'k-icon ion-ios-arrow-right'),
    '_context': $this,
    'ev-click': function () {
      try {
        return self._add;
      } catch (e) {
        _e(e);
      }
    }.call($this)
  })], 'k-arrows'), h(Panel, {
    'data': function () {
      try {
        return value;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'model': 'right',
    'title': function () {
      try {
        return rightTitle;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this
  })], _className(function () {
    try {
      return classNameObj;
    } catch (e) {
      _e(e);
    }
  }.call($this)));
}