import { r as registerInstance, h, H as Host, g as getElement } from './index-b7735e0d.js';
import { m as matchPath, i as isModifiedEvent } from './dom-utils-796b2f82.js';
import { A as ActiveRouter } from './active-router-36ad0201.js';
import './state-tunnel-04c0b67a.js';

const devingenProductCardCss = "devingen-product-card{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:calc(2 * var(--spacing-unit));color:var(--color-text);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}devingen-product-card .icon-container{padding:calc(1.5 * var(--spacing-unit));background:var(--color-background-primary);border-radius:calc(var(--corner-radius) / 3 * 2);margin-right:calc(2 * var(--spacing-unit))}devingen-product-card .icon-container.damga{background:var(--color-primary);color:white}devingen-product-card .icon-container.kimlik{background:var(--color-secondary);color:white}";

const productIcons = {
  damga: 'shield-check',
  kimlik: 'padlock',
};
let DevingenHomePage = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  render() {
    const { product } = this;
    if (!product) {
      return (h(Host, null, h("div", { class: "icon-container" }, h("dvn-icon", { iconName: "uil uil-plus", scale: "large" })), "Add new product"));
    }
    return (h(Host, null, h("div", { class: {
        'icon-container': true,
        [product.type]: true,
      } }, h("dvn-icon", { iconName: `uil uil-${productIcons[product.type] || 'question'}`, scale: "large" })), product.name));
  }
};
DevingenHomePage.style = devingenProductCardCss;

const getUrl = (url, root) => {
  // Don't allow double slashes
  if (url.charAt(0) == '/' && root.charAt(root.length - 1) == '/') {
    return root.slice(0, root.length - 1) + url;
  }
  return root + url;
};
let RouteLink = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.unsubscribe = () => { return; };
    this.activeClass = 'link-active';
    this.exact = false;
    this.strict = true;
    /**
      *  Custom tag to use instead of an anchor
      */
    this.custom = 'a';
    this.match = null;
  }
  componentWillLoad() {
    this.computeMatch();
  }
  // Identify if the current route is a match.
  computeMatch() {
    if (this.location) {
      this.match = matchPath(this.location.pathname, {
        path: this.urlMatch || this.url,
        exact: this.exact,
        strict: this.strict
      });
    }
  }
  handleClick(e) {
    if (isModifiedEvent(e) || !this.history || !this.url || !this.root) {
      return;
    }
    e.preventDefault();
    return this.history.push(getUrl(this.url, this.root));
  }
  // Get the URL for this route link without the root from the router
  render() {
    let anchorAttributes = {
      class: {
        [this.activeClass]: this.match !== null,
      },
      onClick: this.handleClick.bind(this)
    };
    if (this.anchorClass) {
      anchorAttributes.class[this.anchorClass] = true;
    }
    if (this.custom === 'a') {
      anchorAttributes = Object.assign({}, anchorAttributes, { href: this.url, title: this.anchorTitle, role: this.anchorRole, tabindex: this.anchorTabIndex, 'aria-haspopup': this.ariaHaspopup, id: this.anchorId, 'aria-posinset': this.ariaPosinset, 'aria-setsize': this.ariaSetsize, 'aria-label': this.ariaLabel });
    }
    return (h(this.custom, Object.assign({}, anchorAttributes), h("slot", null)));
  }
  get el() { return getElement(this); }
  static get watchers() { return {
    "location": ["computeMatch"]
  }; }
};
ActiveRouter.injectProps(RouteLink, [
  'history',
  'location',
  'root'
]);

export { DevingenHomePage as devingen_product_card, RouteLink as stencil_route_link };
