import { __extends, __decorate, __metadata } from 'tslib';
import { Prop, Component } from 'vue-property-decorator';
import BaseComponent from '../../BaseComponent.js';
import { classNamesFunction } from '@uifabric-vue/utilities';
import { PersonaPresence } from '../Persona.types.js';
import { sizeBoolean } from '../PersonaConsts.js';
import { Icon } from '../../Icon/Icon.js';

var coinSizeFontScaleFactor = 6;
var coinSizePresenceScaleFactor = 3;
var presenceMaxSize = 40;
var presenceFontMaxSize = 20;
var getClassNames = classNamesFunction({
  cacheSize: 100
});
var PersonaPresenceBase = function(_super) {
  __extends(PersonaPresenceBase2, _super);
  function PersonaPresenceBase2() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.PersonaPresenceEnum = PersonaPresence;
    return _this;
  }
  Object.defineProperty(PersonaPresenceBase2.prototype, "renderIcon", {
    get: function() {
      var coinSize = this.coinSize;
      var size = sizeBoolean(this.size);
      return !(size.isSize8 || size.isSize10 || size.isSize16 || size.isSize24 || size.isSize28 || size.isSize32) && (coinSize ? coinSize > 32 : true);
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaPresenceBase2.prototype, "presenceHeightWidth", {
    get: function() {
      var coinSize = this.coinSize;
      var presenceHeightWidth = coinSize ? coinSize / coinSizePresenceScaleFactor < presenceMaxSize ? coinSize / coinSizePresenceScaleFactor + "px" : presenceMaxSize + "px" : "";
      return presenceHeightWidth;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaPresenceBase2.prototype, "coinSizeWithPresenceStyle", {
    get: function() {
      var _a = this, coinSize = _a.coinSize, presenceHeightWidth = _a.presenceHeightWidth;
      return coinSize ? { width: presenceHeightWidth, height: presenceHeightWidth } : void 0;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaPresenceBase2.prototype, "coinSizeWithPresenceIconStyle", {
    get: function() {
      var _a = this, coinSize = _a.coinSize; _a.isOutOfOffice; _a.styles; _a.presence; _a.presenceTitle; var presenceHeightWidth = _a.presenceHeightWidth;
      sizeBoolean(this.size);
      var presenceFontSize = coinSize ? coinSize / coinSizeFontScaleFactor < presenceFontMaxSize ? coinSize / coinSizeFontScaleFactor + "px" : presenceFontMaxSize + "px" : "";
      return coinSize ? { fontSize: presenceFontSize, lineHeight: presenceHeightWidth } : void 0;
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaPresenceBase2.prototype, "classNames", {
    get: function() {
      var _a = this, styles = _a.styles, theme = _a.theme, presence = _a.presence, size = _a.size, isOutOfOffice = _a.isOutOfOffice;
      return getClassNames(styles, {
        theme: theme,
        presence: presence,
        size: size,
        isOutOfOffice: isOutOfOffice
      });
    },
    enumerable: false,
    configurable: true
  });
  Object.defineProperty(PersonaPresenceBase2.prototype, "icon", {
    get: function() {
      var _a = this, presence = _a.presence, isOutOfOffice = _a.isOutOfOffice;
      if (!presence) {
        return void 0;
      }
      var oofIcon = "SkypeArrow";
      switch (PersonaPresence[presence]) {
        case "online":
          return "SkypeCheck";
        case "away":
          return isOutOfOffice ? oofIcon : "SkypeClock";
        case "dnd":
          return "SkypeMinus";
        case "offline":
          return isOutOfOffice ? oofIcon : "";
      }
      return "";
    },
    enumerable: false,
    configurable: true
  });
  PersonaPresenceBase2.prototype.render = function(h) {
    var _a = this, classNames = _a.classNames, presence = _a.presence, presenceTitle = _a.presenceTitle, coinSizeWithPresenceStyle = _a.coinSizeWithPresenceStyle, coinSizeWithPresenceIconStyle = _a.coinSizeWithPresenceIconStyle, icon = _a.icon, renderIcon = _a.renderIcon;
    if (presence === PersonaPresence.none)
      return;
    return h("div", {
      class: classNames.presence,
      attrs: {
        title: presenceTitle
      },
      style: coinSizeWithPresenceStyle
    }, [
      renderIcon && h(Icon, {
        class: classNames.presenceIcon,
        style: coinSizeWithPresenceIconStyle,
        props: {
          iconName: icon
        }
      })
    ]);
  };
  __decorate([
    Prop({ type: Number, required: true }),
    __metadata("design:type", Number)
  ], PersonaPresenceBase2.prototype, "presence", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaPresenceBase2.prototype, "size", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaPresenceBase2.prototype, "isOutOfOffice", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaPresenceBase2.prototype, "coinSize", void 0);
  __decorate([
    Prop(),
    __metadata("design:type", Object)
  ], PersonaPresenceBase2.prototype, "presenceTitle", void 0);
  PersonaPresenceBase2 = __decorate([
    Component({
      components: { Icon: Icon },
      name: "PersonaPresence"
    })
  ], PersonaPresenceBase2);
  return PersonaPresenceBase2;
}(BaseComponent);

export { PersonaPresenceBase };
