'use strict';

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

const index = require('./index-1ee80297.js');
const User = require('./User-286a0714.js');
const index$1 = require('./index-5036e660.js');
require('./data-model-c51de090.js');
require('./context-b40e422f.js');
require('./state-tunnel-786a62ce.js');

const dvnAppActivateMembershipCss = "dvn-app-activate-membership{display:block}dvn-app-activate-membership .space-logo{width:48px;height:48px;-ms-flex:0 0 48px;flex:0 0 48px;margin-right:0.5rem}";

function wrapContent(content) {
  return (index.h(index.Host, { class: "d-block row justify-content-center pt-3" }, index.h("div", { class: "col mt-3" }, content)));
}
let DvnAppActivateMembership = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.renderTrigger = 0;
    this.isProgressing = false;
  }
  async activateMembership() {
    const { membership } = this;
    const result = await this.apiUye.activateMembership(membership.config._id, membership._id).catch(e => {
      console.log(e);
    });
    if (!result)
      return;
    this.appContextInvalidator();
  }
  render() {
    const { membership, user } = this;
    if (!membership) {
      return wrapContent(index.h("dvn-progress", { indefinite: true }));
    }
    // TODO handle this scenario
    // if membership and session users don't match, show 'mismatch user' message
    // if (isUserLoggedIn() && getSessionData().uid !== membership.user._id) {
    //   return wrapContent(
    //     <div class="d-flex flex-column align-items-center">
    //       <p>
    //         This membership is created for <b>{membership.user.email} </b>
    //         but you're logged in from a different account. Please logout in order to proceed.
    //       </p>
    //       <kimlik-logout-action redirectTo={location.pathname} sendApiRequest={false}>
    //         <dvn-button shape="rounded" tint="primary">
    //           Logout
    //         </dvn-button>
    //       </kimlik-logout-action>
    //     </div>
    //   );
    // }
    return wrapContent(index.h("div", { class: "text-centered" }, index.h("div", { class: "d-flex align-items-center justify-content-center" }, index.h("dvn-image", { bordered: true, src: membership.config.space.logoUrl, size: 64, text: membership.config.space.name[0] }), index.h("dvn-icon", { iconName: "uil uil-plus", scale: "large" }), index.h("dvn-image", { bordered: true, src: user.imageUrl, size: 64, shape: "circle", text: User.getUserInitials(user) })), index.h("p", null, "You're invited as ", index.h("i", null, membership.config.roleName), " to join ", membership.config.space.name, "."), index.h("dvn-button", { onClick: () => this.activateMembership(), tint: "primary" }, "Accept Invitation")));
  }
  get el() { return index.getElement(this); }
};
index$1.injectContext(DvnAppActivateMembership);
DvnAppActivateMembership.style = dvnAppActivateMembershipCss;

exports.dvn_app_activate_membership = DvnAppActivateMembership;
