'use strict';

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

const index = require('./index-a48c06e5.js');
require('./index-a47a21ac.js');
const runStore = require('./runStore-c13c5254.js');

const BaseLink = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.routeChange = index.createEvent(this, "routeChange", 7);
    this.style = [];
    this.color = "--cj-color-primary";
    this.hoverColor = "--cj-color-secondary";
    this.decoration = "--cj-link-decoration";
    this.hoverDecoration = "--cj-link-hover-decoration";
  }
  async componentWillLoad() {
    await this.computeStyles();
  }
  async computeStyles() {
    const hash = await (await Promise.resolve().then(function () { return require('./style-955ebe54.js'); }).then(function (n) { return n.style; })).calculateStyles(this);
    this.hash = hash;
  }
  renderLink() {
    if (runStore.runState.router) {
      const defaultProps = runStore.href(this.href, runStore.runState.router);
      const overwrittenProps = Object.assign(Object.assign({}, defaultProps), { onClick: (ev) => {
          this.routeChange.emit({ type: "routechange", newUrl: this.href });
          if (typeof defaultProps.onClick === "function")
            defaultProps.onClick(ev);
          window.scrollTo({ top: 0 });
        } });
      return (index.h("a", Object.assign({}, overwrittenProps, { class: this.hash }), index.h("slot", null)));
    }
    return (index.h("a", { href: this.href, class: this.hash }, index.h("slot", null)));
  }
  render() {
    return index.h(index.Host, { class: this.hash }, this.renderLink());
  }
};

exports.corejam_base_link = BaseLink;
