import { injectContext } from '@dvn/core/global/context';
import { getActivateMembershipRouteParams } from '@dvn/core/util/route';
import { Component, h, Listen, Prop } from '@stencil/core';
export class DvnAppAnonymous {
  constructor() {
    this.isLandingPage = () => this.path === '/';
    this.isLoginPage = () => this.path === '/login';
    this.getRouteParams = () => getActivateMembershipRouteParams(this.path);
    this.wrapContent = (content) => (h("dvn-theme-provider", { colorBackground: true, fitHeight: true, theme: this.theme },
      h("dvn-global-grid", null),
      content));
  }
  onAction(event) {
    event.stopImmediatePropagation();
    const action = event.detail;
    if (action.type === 'navigation') {
      const navigateAction = action;
      if (navigateAction.direction === 'forward') {
        const navigateForwardAction = action;
        const route = navigateForwardAction.url;
        this.navigate({ path: route });
      }
    }
  }
  ;
  render() {
    if (this.isLandingPage() || this.isLoginPage()) {
      return this.wrapContent(h("dvn-app-login-page", null));
    }
    const { spaceId, membershipConfigId, membershipId } = this.getRouteParams();
    if (!!spaceId && !!membershipConfigId && !!membershipId) {
      // if all parameters are here, load activation page
      return this.wrapContent(h("dvn-app-activate-membership-anonymous", { navigate: this.navigate, path: this.path }));
    }
    return this.wrapContent(h("dvn-not-found", null));
  }
  static get is() { return "dvn-app-anonymous"; }
  static get properties() { return {
    "navigate": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "NavigationHandler",
        "resolved": "(config: NavigateConfig) => void",
        "references": {
          "NavigationHandler": {
            "location": "import",
            "path": "@dvn/core/routing/routing"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "path": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "path",
      "reflect": false
    },
    "theme": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "AlacaTheme",
        "resolved": "AlacaTheme",
        "references": {
          "AlacaTheme": {
            "location": "import",
            "path": "@dvn/alaca/theme"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get listeners() { return [{
      "name": "action",
      "method": "onAction",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
injectContext(DvnAppAnonymous);
